-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(719): text cropping storybook (#781)
* docs(XXXX-0000): closes 719 * docs(XXX-0000): add sort-order alphabetic * docs(719): remove un-used comment
- Loading branch information
Showing
3 changed files
with
89 additions
and
217 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import * as React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import {TextBlock} from '../../text-block'; | ||
import {TypographyPreset, useTheme} from '../../theme'; | ||
import {StorybookPage, StorybookCase} from '../../test/storybook-comps'; | ||
import {getColorCssFromTheme} from '../../utils'; | ||
|
||
export default { | ||
title: 'Components/Text cropping', | ||
component: () => 'None', | ||
parameters: { | ||
nkDocs: { | ||
title: 'Text Cropping', | ||
url: 'https://newskit.co.uk/theme/foundation/fonts/#textcrop', | ||
description: '', | ||
}, | ||
}, | ||
}; | ||
|
||
const StyledTextBlock = styled(TextBlock)` | ||
${getColorCssFromTheme('backgroundColor', 'interactivePrimary010')} | ||
`; | ||
|
||
const renderTextBlockWithPreset = ( | ||
presetPrefix: string, | ||
typographyPresets: Record<string, TypographyPreset>, | ||
) => { | ||
const presetList = Object.keys(typographyPresets).filter(preset => | ||
preset.startsWith(presetPrefix), | ||
); | ||
|
||
return presetList.map((preset: string) => ( | ||
<StorybookCase title={` ${preset}`}> | ||
<StyledTextBlock stylePreset="inkBase" typographyPreset={preset}> | ||
The quick brown fox | ||
</StyledTextBlock> | ||
</StorybookCase> | ||
)); | ||
}; | ||
|
||
export const EditorialCropping = () => { | ||
const {typographyPresets} = useTheme(); | ||
|
||
const presetsKeys = [ | ||
'editorialDisplay', | ||
'editorialHeadline', | ||
'editorialSubheadline', | ||
'editorialParagraph', | ||
'editorialQuote', | ||
'editorialCaption', | ||
'editorialLabel', | ||
]; | ||
|
||
return ( | ||
<StorybookPage columns="1fr"> | ||
{presetsKeys.map(presetKey => | ||
renderTextBlockWithPreset(presetKey, typographyPresets), | ||
)} | ||
</StorybookPage> | ||
); | ||
}; | ||
EditorialCropping.storyName = 'Editorial cropping'; | ||
|
||
export const UtilityCropping = () => { | ||
const {typographyPresets} = useTheme(); | ||
|
||
const presetsKeys = [ | ||
'utilityHeading', | ||
'utilitySubheading', | ||
'utilityBody', | ||
'utilityLabel', | ||
'utilityButton', | ||
'utilityMeta', | ||
]; | ||
|
||
return ( | ||
<StorybookPage columns="1fr"> | ||
{presetsKeys.map(presetKey => | ||
renderTextBlockWithPreset(presetKey, typographyPresets), | ||
)} | ||
</StorybookPage> | ||
); | ||
}; | ||
UtilityCropping.storyName = 'Utility cropping '; |