Skip to content

Commit

Permalink
Merge 9eabdf8 into 67503ae
Browse files Browse the repository at this point in the history
  • Loading branch information
beaesguerra authored Aug 12, 2024
2 parents 67503ae + 9eabdf8 commit 9edf54a
Show file tree
Hide file tree
Showing 22 changed files with 657 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .changeset/eight-pans-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion __docs__/wonder-blocks-form/_overview_.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import {Meta} from "@storybook/blocks";
# Form

`wonder-blocks-form` provides building blocks form Form components, including
TextField, Choice, Checkbox, RadioButton, etc.
TextField, TextArea, Choice, Checkbox, RadioButton, etc.
34 changes: 34 additions & 0 deletions __docs__/wonder-blocks-form/accessibility.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Meta, Story, Canvas} from "@storybook/blocks";
import * as AccessibilityStories from './accessibility.stories';

<Meta of={AccessibilityStories} />

# Form Accessibility

## Form Field Labels

Form fields should have an associated `<label>` element that has the `htmlFor`
prop set to the `id` of the form field element. This is helpful for
screenreaders so that it can communicate the relationship between the label and
the form field.

### Guidelines
- Make sure the id of the form field element is unique to the page
- Consider using the `LabeledTextField` component if you are using `TextField`.
This will automatically wire up the label and text input. (Note: we will have
a more generic `LabelField` component later on to provide this functionality
for other form fields.)
- If you are using the `CheckboxGroup` or `RadioGroup` components, the accessible
label for the field is already built-in when the `label` prop is used. This
uses `<fieldset>` and `<legend>` elements instead of a `<label>` since the label
is for a group of related controls. See
[Grouping Controls](https://www.w3.org/WAI/tutorials/forms/grouping/)
for more details!
- When using Wonder Blocks typography components for form labels, the `tag`
prop can be set to `label` to change the underlying element to render.


Here is an example of a form field label using Wonder Blocks components
`LabelMedium` and `TextArea`:

<Canvas of={AccessibilityStories.FormLabelExample} />
53 changes: 53 additions & 0 deletions __docs__/wonder-blocks-form/accessibility.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as React from "react";
import {StyleSheet} from "aphrodite";
import {View} from "@khanacademy/wonder-blocks-core";
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
import {TextArea} from "@khanacademy/wonder-blocks-form";
import {spacing} from "@khanacademy/wonder-blocks-tokens";

export default {
title: "Packages / Form / Accessibility",
parameters: {
previewTabs: {
canvas: {
hidden: true,
},
},

viewMode: "docs",

chromatic: {
// Disabling because this is used for documentation purposes
disableSnapshot: true,
},
},
tags: [
"!dev", // Hide individual stories from sidebar so they are only shown in the docs page.
],
};

/**
* An example of a form field label using Wonder Blocks components `LabelMedium`
* and `TextArea`.
*/
export const FormLabelExample = () => {
const [value, setValue] = React.useState("");
return (
<View style={styles.container}>
<LabelMedium tag="label" htmlFor="description-field">
Description
</LabelMedium>
<TextArea
value={value}
onChange={(value) => setValue(value)}
id="description-field"
/>
</View>
);
};

const styles = StyleSheet.create({
container: {
gap: spacing.xSmall_8,
},
});
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/body-monospace.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {BodyMonospace} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / BodyMonospace",
component: BodyMonospace,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof BodyMonospace>;

type StoryComponentType = StoryObj<typeof BodyMonospace>;

export const Default: StoryComponentType = {
args: {
children: "BodyMonospace",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/body-serif-block.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {BodySerifBlock} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / BodySerifBlock",
component: BodySerifBlock,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof BodySerifBlock>;

type StoryComponentType = StoryObj<typeof BodySerifBlock>;

export const Default: StoryComponentType = {
args: {
children: "BodySerifBlock",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/body-serif.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {BodySerif} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / BodySerif",
component: BodySerif,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof BodySerif>;

type StoryComponentType = StoryObj<typeof BodySerif>;

export const Default: StoryComponentType = {
args: {
children: "BodySerif",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/body.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {Body} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / Body",
component: Body,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof Body>;

type StoryComponentType = StoryObj<typeof Body>;

export const Default: StoryComponentType = {
args: {
children: "Body",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/caption.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {Caption} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / Caption",
component: Caption,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof Caption>;

type StoryComponentType = StoryObj<typeof Caption>;

export const Default: StoryComponentType = {
args: {
children: "Caption",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/footnote.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {Footnote} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / Footnote",
component: Footnote,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof Footnote>;

type StoryComponentType = StoryObj<typeof Footnote>;

export const Default: StoryComponentType = {
args: {
children: "Footnote",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/heading-large.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {HeadingLarge} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / HeadingLarge",
component: HeadingLarge,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof HeadingLarge>;

type StoryComponentType = StoryObj<typeof HeadingLarge>;

export const Default: StoryComponentType = {
args: {
children: "HeadingLarge",
},
};
35 changes: 35 additions & 0 deletions __docs__/wonder-blocks-typography/heading-medium.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as React from "react";
import {Meta, StoryObj} from "@storybook/react";
import packageConfig from "../../packages/wonder-blocks-typography/package.json";

import ComponentInfo from "../../.storybook/components/component-info";
import TypographyArgTypes from "./typography.argtypes";

import {HeadingMedium} from "@khanacademy/wonder-blocks-typography";

export default {
title: "Packages / Typography / HeadingMedium",
component: HeadingMedium,
parameters: {
componentSubtitle: (
<ComponentInfo
name={packageConfig.name}
version={packageConfig.version}
/>
),
chromatic: {
// Disabling because all typography components are covered together
// in the Typography stories
disableSnapshot: true,
},
},
argTypes: TypographyArgTypes,
} as Meta<typeof HeadingMedium>;

type StoryComponentType = StoryObj<typeof HeadingMedium>;

export const Default: StoryComponentType = {
args: {
children: "HeadingMedium",
},
};
Loading

0 comments on commit 9edf54a

Please sign in to comment.