-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: updating Heading docs * chore: fixing default level on demo
- Loading branch information
Showing
10 changed files
with
193 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import { | ||
Flex, | ||
HeadingLevel, | ||
HeadingProps, | ||
SelectField, | ||
} from '@aws-amplify/ui-react'; | ||
|
||
interface HeadingPropControlsProps extends HeadingProps { | ||
setLevel: (value: React.SetStateAction<HeadingProps['level']>) => void; | ||
} | ||
|
||
interface HeadingPropControlsInterface { | ||
(props: HeadingPropControlsProps): JSX.Element; | ||
} | ||
|
||
export const HeadingPropControls: HeadingPropControlsInterface = ({ | ||
level, | ||
setLevel, | ||
}) => { | ||
return ( | ||
<Flex direction="column"> | ||
<SelectField | ||
name="level" | ||
value={String(level)} | ||
onChange={(event) => setLevel(+event.target.value as HeadingLevel)} | ||
label="level" | ||
> | ||
<option value="1">1</option> | ||
<option value="2">2</option> | ||
<option value="3">3</option> | ||
<option value="4">4</option> | ||
<option value="5">5</option> | ||
<option value="6">6</option> | ||
</SelectField> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,21 @@ | ||
import React, { useState } from 'react'; | ||
import { Heading, HeadingLevel, Flex, View } from '@aws-amplify/ui-react'; | ||
import { FieldLabeler } from '@/components/FieldLabeler'; | ||
import { Example } from '@/components/Example'; | ||
import * as React from 'react'; | ||
import { Heading, HeadingLevel } from '@aws-amplify/ui-react'; | ||
|
||
import { HeadingPropControls } from './HeadingPropControls'; | ||
import { Demo } from '@/components/Demo'; | ||
|
||
const propsToCode = (level: HeadingLevel) => { | ||
return `<Heading level={${level}}>Heading</Heading>`; | ||
}; | ||
export const HeadingDemo = () => { | ||
const [level, setLevel] = useState<HeadingLevel>(6); | ||
const [level, setLevel] = React.useState<HeadingLevel>(6); | ||
|
||
return ( | ||
<Flex direction="column" gap="1rem"> | ||
<Flex> | ||
<FieldLabeler id="level"> | ||
<select | ||
value={level} | ||
placeholder="Select heading level" | ||
onChange={(event) => setLevel(+event.target.value as HeadingLevel)} | ||
id="level" | ||
name="level" | ||
> | ||
<option value={1}>1</option> | ||
<option value={2}>2</option> | ||
<option value={3}>3</option> | ||
<option value={4}>4</option> | ||
<option value={5}>5</option> | ||
<option value={6}>6</option> | ||
</select> | ||
</FieldLabeler> | ||
</Flex> | ||
<Example> | ||
<View> | ||
<Heading level={level}>Heading</Heading> | ||
</View> | ||
</Example> | ||
</Flex> | ||
<Demo | ||
code={propsToCode(level)} | ||
propControls={<HeadingPropControls level={level} setLevel={setLevel} />} | ||
> | ||
<Heading level={level}>Heading</Heading> | ||
</Demo> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
docs/src/pages/components/heading/examples/DefaultHeadingExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as React from 'react'; | ||
import { Heading } from '@aws-amplify/ui-react'; | ||
|
||
export const DefaultHeadingExample = () => { | ||
return <Heading>Hello world</Heading>; | ||
}; |
16 changes: 16 additions & 0 deletions
16
docs/src/pages/components/heading/examples/HeadingLevelExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react'; | ||
import { Heading } from '@aws-amplify/ui-react'; | ||
|
||
export const HeadingLevelExample = () => { | ||
return ( | ||
<> | ||
<Heading level={1}>Heading 1</Heading> | ||
<Heading level={2}>Heading 2</Heading> | ||
<Heading level={3}>Heading 3</Heading> | ||
<Heading level={4}>Heading 4</Heading> | ||
<Heading level={5}>Heading 5</Heading> | ||
<Heading level={6}>Heading 6</Heading> | ||
<Heading>Default (level 6)</Heading> | ||
</> | ||
); | ||
}; |
15 changes: 15 additions & 0 deletions
15
docs/src/pages/components/heading/examples/HeadingStylePropsExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { Heading, useTheme } from '@aws-amplify/ui-react'; | ||
|
||
export const HeadingStylePropsExample = () => { | ||
const { tokens } = useTheme(); | ||
return ( | ||
<Heading | ||
level={3} | ||
color={tokens.colors.green[80]} | ||
fontWeight={tokens.fontWeights.bold} | ||
> | ||
Hello world | ||
</Heading> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { DefaultHeadingExample } from './DefaultHeadingExample'; | ||
export { HeadingLevelExample } from './HeadingLevelExample'; | ||
export { HeadingStylePropsExample } from './HeadingStylePropsExample'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#subscribe { | ||
color: darkblue; | ||
font-style: italic; | ||
font-size: 1.5rem; | ||
.heading-global-styling { | ||
color: var(--amplify-colors-neutral-80); | ||
} | ||
|
||
.heading-blue { | ||
color: var(--amplify-colors-blue-80); | ||
} |