-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Heading and spacing description (#408)
* wip heading component * heading story * wip * wip * heading component * create description for the spacing * spacing description and fix controls * spacing description and fix controls * spacing description and fix controls
- Loading branch information
Hadas Farhi
authored
Dec 27, 2021
1 parent
6e92948
commit c45a7bd
Showing
17 changed files
with
302 additions
and
62 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
8 changes: 7 additions & 1 deletion
8
src/components/EditableHeading/__stories__/EditableHeading.stories.mdx
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 |
---|---|---|
@@ -0,0 +1,159 @@ | ||
import Heading from "../Heading"; | ||
import { ArgsTable, Story, Canvas, Meta } from "@storybook/addon-docs"; | ||
import { createComponentTemplate, createStoryMetaSettings } from "../../../storybook/functions/create-component-story"; | ||
import { Link, RelatedComponents } from "../../../storybook/components"; | ||
import Divider from "../../Divider/Divider"; | ||
import Search from "../../Search/Search"; | ||
import Checkbox from "../../Checkbox/Checkbox"; | ||
import Button from "../../Button/Button"; | ||
import { Custom } from "../../Icon/Icons"; | ||
import { emptyStateExample } from "./assets"; | ||
import classes from "./Heading.stories.module.scss"; | ||
import { RelatedComponent } from "../../../storybook/components/related-component/related-component"; | ||
import { | ||
EDITABLE_HEADING, | ||
SEARCH, | ||
TEXT_FIELD | ||
} from "../../../storybook/components/related-components/component-description-map"; | ||
|
||
export const argsTypes = createStoryMetaSettings({ | ||
component: Heading, | ||
enumPropNamesArray: ["type", "size"] | ||
}) | ||
|
||
<Meta | ||
title="Text/Heading" | ||
component={ Heading } | ||
argTypes={ argsTypes } | ||
/> | ||
|
||
<!--- Component template --> | ||
|
||
export const headingTemplate = createComponentTemplate(Heading); | ||
|
||
<!--- Component documentation --> | ||
|
||
# Heading | ||
- [Overview](#overview) | ||
- [Props](#props) | ||
- [Usage](#usage) | ||
- [Variants](#variants) | ||
- [Do’s and don’ts](#dos-and-donts) | ||
- [Use cases and examples](#use-cases-and-examples) | ||
- [Related components](#related-components) | ||
- [Feedback](#feedback) | ||
|
||
## Overview | ||
Heading components are used to title any page sections or sub-sections in top-level page sections. | ||
|
||
<Canvas> | ||
<Story name="Overview" | ||
args={{ value: "Hello world" }}> | ||
{ headingTemplate.bind({}) } | ||
</Story> | ||
</Canvas> | ||
|
||
## Props | ||
<ArgsTable of={ Heading } /> | ||
|
||
## Usage | ||
<UsageGuidelines guidelines={[ | ||
"Never include more than one H1 title per web page", | ||
"Heading always should be linked to content (by design and by implementation by passing the heading id to the content's aria-labelledBy attribute)", | ||
]}/> | ||
|
||
<Tip title="Not what you were looking for?">Please check out our <Link href="/?path=/docs/inputs-editableheading--overview" withoutSpacing>EditableHeading</Link> component if you would like to allow users to edit the title text..</Tip> | ||
|
||
## Variants | ||
### Story title 1 | ||
<Canvas> | ||
<Story name="Types"> | ||
<div style={{display: "flex", flexDirection: "column" }}> | ||
<Heading type={Heading.types.h1} value="Hello H1" /> | ||
<Heading type={Heading.types.h1} value="Hello H1 medium" size="medium" /> | ||
<Heading type={Heading.types.h2} value="Hello H2" /> | ||
<Heading type={Heading.types.h2} value="Hello H2 small" size="small" /> | ||
<Heading type={Heading.types.h3} value="Hello H3" /> | ||
<Heading type={Heading.types.h4} value="Suggest Edit H4" suggestEditOnHover /> | ||
<Heading type={Heading.types.h5} value="H5 with tooltip" nonEllipsisTooltip="Click to edit" /> | ||
</div> | ||
</Story> | ||
</Canvas> | ||
|
||
### Overflow | ||
Our heading components support overflow state. | ||
When the heading text is too long and the component includes an ellipsis flag, we will cut the end of the heading and display instead of it "...". | ||
<Canvas> | ||
<Story name="Overflow"> | ||
<div style={{display: "flex", flexDirection: "column", width: "70%"}}> | ||
<Heading | ||
type={Heading.types.h2} | ||
value="Heading without overflow heading without overflow heading without overflow" | ||
ellipsis={false} | ||
nonEllipsisTooltip="Non ellipsis tooltip" | ||
/> | ||
<Heading | ||
type={Heading.types.h2} | ||
value="Heading with overflow heading with overflow heading with overflow heading with overflow heading with overflow" | ||
ellipsis | ||
nonEllipsisTooltip="Non ellipsis tooltip (this tooltip is not shown since overflow)" | ||
/> | ||
<div> | ||
<Heading | ||
type={Heading.types.h2} | ||
value="Heading with overflow when text is longer then 2 lines heading with overflow when text is longer then 2 lines heading with overflow when text is longer then 2 lines" | ||
ellipsisMaxLines={2} | ||
nonEllipsisTooltip="Non ellipsis tooltip (this tooltip is not shown since overflow)" | ||
/> | ||
</div> | ||
</div> | ||
</Story> | ||
</Canvas> | ||
|
||
## Do’s and Don’ts | ||
<ComponentRules | ||
rules={[ | ||
{ | ||
positive: { | ||
component:<Heading value="Hello world"/>, | ||
description:"Always capitalize the first letter of the first word in the heading." | ||
}, | ||
negative: { | ||
component:<Heading value="Hello World"/>, | ||
description:"Please avoid capitalizing the first letter of each word in the heading." | ||
} | ||
} | ||
]} | ||
/> | ||
|
||
|
||
## Use cases and examples | ||
|
||
### Not editable header of a page | ||
<Canvas> | ||
<Story name="Not editable header of a page"> | ||
<div style={{width: "100%"}}> | ||
<Heading type={Heading.types.h1} value="My Work"/> | ||
<Divider/> | ||
<div className={classes["page-header_commands"]} style={{display: "flex", alignItems: "center"}} > | ||
<Search wrapperClassName={classes["page-header_search"]} placeholder="Search"/> | ||
<Checkbox label="Hide done items" checked /> | ||
<Button leftIcon={Custom} kind={Button.kinds.TERTIARY}>Customize</Button> | ||
</div> | ||
</div> | ||
</Story> | ||
</Canvas> | ||
|
||
### Empty state title | ||
<Canvas> | ||
<Story name="Empty state title"> | ||
<div className={classes["empty-state-container"]}> | ||
<img style={{width: "290px"}} src={emptyStateExample} alt="" /> | ||
<Heading type={Heading.types.h2} value="No updates yet for this item"/> | ||
<span style={{width: "50%", textAlign: "center"}}>Be the first one to update about progress, mention someone or upload files to share with your team members</span> | ||
</div> | ||
</Story> | ||
</Canvas> | ||
|
||
## Related components | ||
<RelatedComponents componentsNames={[EDITABLE_HEADING, TEXT_FIELD, SEARCH]}/> |
20 changes: 20 additions & 0 deletions
20
src/components/Heading/__stories__/Heading.stories.module.scss
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,20 @@ | ||
@import "../../../styles/themes.scss"; | ||
|
||
.empty-state-container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
padding: var(--spacing-large); | ||
} | ||
|
||
.page-header_commands { | ||
margin-top: var(--spacing-large); | ||
& > * { | ||
margin-left: var(--spacing-small); | ||
} | ||
} | ||
.page-header_search { | ||
width: 146px; | ||
} |
1 change: 1 addition & 0 deletions
1
src/components/Heading/__stories__/assets/emptyStateExample.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
import emptyStateExample from "./emptyStateExample.svg"; | ||
|
||
export { emptyStateExample }; |
This file was deleted.
Oops, something went wrong.
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
20 changes: 20 additions & 0 deletions
20
src/storybook/components/related-components/descriptions/editable-heading-description.jsx
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,20 @@ | ||
import { useMemo } from "react"; | ||
import { RelatedComponent } from "../../related-component/related-component"; | ||
import EditableHeading from "../../../../components/EditableHeading/EditableHeading"; | ||
|
||
export const EditableHeadingDescription = () => { | ||
const component = useMemo(() => { | ||
return ( | ||
<div> | ||
<EditableHeading value="Hello world" type={EditableHeading.types.h3} /> | ||
</div> | ||
); | ||
}, []); | ||
return ( | ||
<RelatedComponent | ||
component={component} | ||
title="Editable heading" | ||
description="An extension of Heading component, it allows built in editing capabilities." | ||
/> | ||
); | ||
}; |
23 changes: 23 additions & 0 deletions
23
...ok/components/related-components/descriptions/spacing-description/spacing-description.jsx
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,23 @@ | ||
import { useMemo } from "react"; | ||
import { RelatedComponent } from "../../../related-component/related-component"; | ||
import classes from "./spacing-description.module.scss"; | ||
|
||
export const SpacingDescription = () => { | ||
const component = useMemo( | ||
() => ( | ||
<div className={classes["spacing-description-visual-element"]}> | ||
<div className={classes["small-spacing-visual-element"]} /> | ||
<div className={classes["medium-spacing-visual-element"]} /> | ||
<div className={classes["large-spacing-visual-element"]} /> | ||
</div> | ||
), | ||
[] | ||
); | ||
return ( | ||
<RelatedComponent | ||
component={component} | ||
title="Spacing" | ||
description="Spacing creates relationships and hierarchy withing the visual controls." | ||
/> | ||
); | ||
}; |
Oops, something went wrong.