From b7b1561750ea3dd5a2f9c940dfea29e5e1181a06 Mon Sep 17 00:00:00 2001 From: evgenitsn Date: Thu, 1 Dec 2022 15:19:50 +0200 Subject: [PATCH] docs(PPDSC-2474): add overrides storybook themes support --- src/banner/__tests__/banner.stories.tsx | 12 +- src/block/__tests__/block.stories.tsx | 14 +- .../__tests__/character-count.stories.tsx | 204 ++++++++++-------- src/divider/__tests__/divider.stories.tsx | 67 +++--- src/test/theme-select-object.ts | 75 +++++-- .../themes/storybook-newskit-dark/colors.json | 72 +++++++ .../storybook-newskit-dark-theme.ts | 9 + .../storybook-newskit-light/colors.json | 178 +++++++++++++++ .../storybook-newskit-light-theme.ts | 9 + 9 files changed, 508 insertions(+), 132 deletions(-) create mode 100644 src/theme-checker/themes/storybook-newskit-dark/colors.json create mode 100644 src/theme-checker/themes/storybook-newskit-dark/storybook-newskit-dark-theme.ts create mode 100644 src/theme-checker/themes/storybook-newskit-light/colors.json create mode 100644 src/theme-checker/themes/storybook-newskit-light/storybook-newskit-light-theme.ts diff --git a/src/banner/__tests__/banner.stories.tsx b/src/banner/__tests__/banner.stories.tsx index c07137289d..76f97d0c9e 100644 --- a/src/banner/__tests__/banner.stories.tsx +++ b/src/banner/__tests__/banner.stories.tsx @@ -313,9 +313,9 @@ export const StoryLogicalProps = () => ( ); StoryLogicalProps.storyName = 'Logical props'; -export const StoryOverrides = () => ( +export const StoryStylingOverrides = () => ( - +
( ); -StoryOverrides.storyName = 'Overrides'; +StoryStylingOverrides.storyName = 'Styling overrides'; export default { title: 'Components/Banner', @@ -387,11 +387,15 @@ export default { }, }, decorators: [ - (Story: StoryType, context: {globals: {backgrounds: {value: string}}}) => ( + ( + Story: StoryType, + context: {name: string; globals: {backgrounds: {value: string}}}, + ) => ( diff --git a/src/block/__tests__/block.stories.tsx b/src/block/__tests__/block.stories.tsx index 30976a9d74..59bfee25fc 100644 --- a/src/block/__tests__/block.stories.tsx +++ b/src/block/__tests__/block.stories.tsx @@ -141,7 +141,7 @@ export const StoryTransitions = () => ( ); StoryTransitions.storyName = 'Transitions'; -export const StoryOverrides = () => ( +export const StoryStylingOverrides = () => ( @@ -158,6 +158,12 @@ export const StoryOverrides = () => ( + +); +StoryStylingOverrides.storyName = 'Styling overrides'; + +export const StoryOverrides = () => ( + ( + ( + Story: StoryType, + context: {name: string; globals: {backgrounds: {value: string}}}, + ) => ( diff --git a/src/character-count/__tests__/character-count.stories.tsx b/src/character-count/__tests__/character-count.stories.tsx index 072b537bb2..1724aeedbd 100644 --- a/src/character-count/__tests__/character-count.stories.tsx +++ b/src/character-count/__tests__/character-count.stories.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import {useRef, useState} from 'react'; +import {Story as StoryType} from '@storybook/react'; import {CharacterCount, CharacterCountProps} from '..'; import { Form, @@ -14,17 +15,29 @@ import {TextArea, TextAreaProps} from '../../text-area'; import {Label} from '../../label'; import {TextField, TextFieldSize} from '../../text-field'; import {FormInputState} from '../../form/types'; -import {createTheme, newskitLightTheme, ThemeProvider} from '../../theme'; +import {CreateThemeArgs, newskitLightTheme, ThemeProvider} from '../../theme'; import {deepMerge} from '../../utils'; import {StorybookCase, StorybookPage} from '../../test/storybook-comps'; +import {createCustomThemeWithBaseThemeSwitch} from '../../test/theme-select-object'; -export default { - title: 'Components/Character count', - parameters: { - nkDocs: { - title: 'Character count', - description: - 'The Character count lets users know how much text they can enter in an input field as they type.', +const myCustomTheme: CreateThemeArgs = { + name: 'my-custom-theme', + overrides: { + stylePresets: { + characterCountCustom: { + base: { + color: '{{colors.inkBrand010}}', + }, + }, + textAreaCustom: deepMerge(newskitLightTheme.stylePresets.inputField, { + base: { + borderWidth: '{{borders.borderWidth020}}', + borderRadius: '{{borders.borderRadiusRounded030}}', + borderColor: '{{colors.teal060}}', + placeholderColor: '{{colors.teal060}}', + color: '{{colors.teal060}}', + }, + }), }, }, }; @@ -286,93 +299,106 @@ export const CharacterCountForm = () => ( ); CharacterCountForm.storyName = 'Form with submit validation'; -const myCustomTheme = createTheme({ - name: 'my-custom-theme', - overrides: { - stylePresets: { - characterCountCustom: { - base: { - color: '{{colors.teal060}}', - }, - }, - textAreaCustom: deepMerge(newskitLightTheme.stylePresets.inputField, { - base: { - borderWidth: '{{borders.borderWidth020}}', - borderRadius: '{{borders.borderRadiusRounded030}}', - borderColor: '{{colors.teal060}}', - placeholderColor: '{{colors.teal060}}', - color: '{{colors.teal060}}', - }, - }), - }, - }, -}); +export const CharacterCountStylingOverrides = () => { + const styleRef = useRef(null); + return ( + + + +