From 1491135302bce9ce57d74c6d11ef579ccc33b771 Mon Sep 17 00:00:00 2001 From: Fazza Razaq Amiarso <86255053+fazzaamiarso@users.noreply.github.com> Date: Sat, 8 Oct 2022 02:23:32 +0700 Subject: [PATCH] [feat]: Implement form theme (#69) --- packages/astro-reactive-form/Form.astro | 7 +++++-- .../astro-reactive-form/test/Form.astro.test.js | 17 ++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/astro-reactive-form/Form.astro b/packages/astro-reactive-form/Form.astro index 434e765..ef2f87e 100644 --- a/packages/astro-reactive-form/Form.astro +++ b/packages/astro-reactive-form/Form.astro @@ -6,12 +6,15 @@ import FieldSet from './components/FieldSet.astro'; export interface Props { submitControl?: Submit; formGroups: FormGroup[]; + theme?: "light" | "dark"; } -const { submitControl, formGroups } = Astro.props; +const { submitControl, formGroups, theme } = Astro.props; + +const formTheme = theme ?? "light"; --- -
+ {formGroups?.map((group) =>
)} {submitControl && } diff --git a/packages/astro-reactive-form/test/Form.astro.test.js b/packages/astro-reactive-form/test/Form.astro.test.js index bb3945e..631a2a9 100644 --- a/packages/astro-reactive-form/test/Form.astro.test.js +++ b/packages/astro-reactive-form/test/Form.astro.test.js @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { describe, beforeEach, it } from 'mocha'; import { getComponentOutput } from 'astro-component-tester'; describe('Form.astro test', () => { @@ -44,12 +45,14 @@ describe('Form.astro test', () => { const expectedCount = 3; const element = /
/g; const fakeFormGroup = { - controls: [{ - type: 'checkbox', - name: 'fake-checkbox', - label: 'FAKE CHECKBOX' - }] - } + controls: [ + { + type: 'checkbox', + name: 'fake-checkbox', + label: 'FAKE CHECKBOX', + }, + ], + }; const props = { formGroups: Array(expectedCount).fill(fakeFormGroup) }; component = await getComponentOutput('./Form.astro', props); @@ -59,7 +62,7 @@ describe('Form.astro test', () => { // assert expect(matches.length).to.equal(expectedCount); - }) + }); }); });