diff --git a/.storybook/main.ts b/.storybook/main.ts index 8d181c8db4..1dff5b43c7 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -20,6 +20,7 @@ import type { StorybookConfig } from '@storybook/react-webpack5'; const config: StorybookConfig = { stories: [ + '../packages/*/src/**/*.stories.@(ts|tsx)', '../examples/**/{stories,*.stories}.@(ts|tsx|js|jsx)', ], addons: [ diff --git a/babel.config.js b/babel.config.js index ec84fa13e5..4027f69376 100644 --- a/babel.config.js +++ b/babel.config.js @@ -60,6 +60,7 @@ module.exports = { !!( fileName.includes('-test') || fileName.includes('-Test') || + fileName.includes('.stories') || /\/node_modules\//.test(fileName) || fileName.includes('.d.ts') || fileName.includes('.figma.tsx') diff --git a/examples/bpk-component-badge/BadgeLayout.tsx b/examples/bpk-component-badge/BadgeLayout.tsx deleted file mode 100644 index addf2a3fc0..0000000000 --- a/examples/bpk-component-badge/BadgeLayout.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2016 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { ReactNode } from 'react'; - -import { cssModules } from '../../packages/bpk-react-utils'; - -import STYLES from './BpkBadgeLayout.module.scss'; - -const getClassName = cssModules(STYLES); - -type Props = { - docked?: string | null; - children: ReactNode; -}; - -const BadgeLayout = ({ children, docked = null }: Props) => { - const classNames = getClassName( - 'bpk-badge-layout__container', - docked && 'bpk-badge-layout__container--light', - ); - - return
{children}
; -}; - -export default BadgeLayout; diff --git a/examples/bpk-component-badge/stories.tsx b/examples/bpk-component-badge/stories.tsx deleted file mode 100644 index c01e5f8369..0000000000 --- a/examples/bpk-component-badge/stories.tsx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2016 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import BpkBadge from '../../packages/bpk-component-badge/src/BpkBadge'; - -import { - DefaultExample, - WarningExample, - SuccessExample, - CriticalExample, - InverseExample, - OutlineExample, - StrongExample, - BrandExample, - CenteredExample, - DockedLeadingExample, - DockedTrailingExample, - MixedExample, - ThemedCornerRadiusExample, - ThemedBackgroundColorExample, - ThemedIconColorExample, - ThemedTypographyExample, -} from './examples'; - -export default { - title: 'bpk-component-badge', - component: BpkBadge, -}; - -export const Default = DefaultExample; -export const Warning = WarningExample; -export const Success = SuccessExample; -export const Critical = CriticalExample; -export const Strong = StrongExample; -export const Brand = BrandExample; -export const Inverse = InverseExample; -export const Outline = OutlineExample; -export const Centered = CenteredExample; -export const DockedRight = DockedLeadingExample; -export const DockedLeft = DockedTrailingExample; -export const ThemedCornerRadius = ThemedCornerRadiusExample; -export const ThemedBackgroundColor = ThemedBackgroundColorExample; -export const ThemedIconColor = ThemedIconColorExample; -export const ThemedTypography = ThemedTypographyExample; - -export const VisualTest = MixedExample; -export const VisualTestWithZoom = { - render: VisualTest, - args: { - zoomEnabled: true, - }, -}; diff --git a/examples/bpk-component-button/stories.tsx b/examples/bpk-component-button/stories.tsx deleted file mode 100644 index 7b64c21fb7..0000000000 --- a/examples/bpk-component-button/stories.tsx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2016 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import BpkButton from '../../packages/bpk-component-button'; - -import { - PrimaryExample, - PrimaryOnDarkExample, - PrimaryOnLightExample, - SecondaryExample, - SecondaryOnDarkExample, - DestructiveExample, - FeaturedExample, - LinkExample, - LinkOnDarkExample, - LinksExamples, - MixedExample, - AnchorTagsExample, - FullWidthExample, - SubmitButtonExample, - ThemedBorderRadiusExample, -} from './examples'; - -export default { - title: 'bpk-component-button', - component: BpkButton, -}; - -export const BpkButtonPrimary = () => ; - -export const BpkButtonPrimaryOnDark = () => ; - -export const BpkButtonPrimaryOnLight = () => ; - -export const BpkButtonSecondary = () => ; - -export const BpkButtonSecondaryOnDark = () => ; - -export const BpkButtonDestructive = () => ; - -export const BpkButtonFeatured = () => ; - -export const BpkButtonLinkButton = () => ; - -export const BpkButtonLinkOnDarkButton = () => ; - -export const BpkButtonLinks = () => ; - -export const Mixture = () => ; -export const AnchorTags = () => ; - -export const VisualTest = () => ; -export const VisualTestWithZoom = { - render: VisualTest, - args: { - zoomEnabled: true, - }, -}; - -export const SubmitButton = () => ; -export const FullWidth = () => ; - -export const ThemedCornerRadius = () => ; diff --git a/examples/bpk-component-card/examples.js b/examples/bpk-component-card/examples.js deleted file mode 100644 index fc3c446ef6..0000000000 --- a/examples/bpk-component-card/examples.js +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2016 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* @flow strict */ - -import { Fragment } from 'react'; - -import { - coreAccentDay, - surfaceHighlightDay, -} from '@skyscanner/bpk-foundations-web/tokens/base.es6'; - -import BpkCard, { - BpkDividedCard, - BpkCardWrapper, - ORIENTATION, -} from '../../packages/bpk-component-card'; -import BpkText, { TEXT_STYLES } from '../../packages/bpk-component-text'; -import { cssModules } from '../../packages/bpk-react-utils'; - -import STYLES from './examples.module.scss'; - -const getClassName = cssModules(STYLES); - -const shortContent = 'Book your next trip on skyscanner.net.'; -const longMessage = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sagittis sagittis purus, id -blandit ipsum. Pellentesque nec diam nec erat condimentum dapibus. Nunc diam augue, egestas id egestas ut, facilisis -nec mi. Donec et congue odio, nec laoreet est. Integer rhoncus varius arcu, a fringilla libero laoreet at. Mauris -porta varius ullamcorper. Sed laoreet libero mauris, non pretium lectus accumsan et. Suspendisse vehicula ullamcorper -sapien, et dapibus mi aliquet non. Pellentesque auctor sagittis lectus vitae rhoncus. Fusce id enim porttitor, mattis -ante in, vestibulum nulla.`; -const headerContent = ( -
- - Wrapper title - -
-); -const longContent = ( - - - Let's explore - - - It's your world and we'll help you explore it. Find the best - prices across millions of flights, hotels and car hire options to create - your perfect trip. -
-
-
-); - -const DefaultExample = () => ( - window.open('https://www.skyscanner.net/')}> - {shortContent} - -); - -const WithHrefExample = () => ( - {shortContent} -); - -const WithoutPaddingExample = () => ( - window.open('https://www.skyscanner.net/')} - > - {shortContent} - -); - -const NonAtomicExample = () => ( - window.open('https://www.skyscanner.net/')} - > - {longContent} - -); - -const NonAtomicHrefExample = () => ( - - {longContent} - -); - -const DefaultDividedCardExample = () => ( - -); - -const VerticalDividedCardExample = () => ( - -); -const WithHrefDividedCardExample = () => ( - -); - -const NonElevatedDividedCardExample = () => ( - -); - -const CardWrapperExample = () => ( - window.open('https://www.skyscanner.net/')} - > - {longContent} - - } - header={headerContent} - /> -); - -const DividedCardWrapperExample = () => ( - - } - header={headerContent} - /> -); - -const WithClassNameWrapperExample = () => ( - window.open('https://www.skyscanner.net/')} - > - {longContent} - - } - header={headerContent} - className={getClassName('bpk-card-examples__wrapper')} - /> -); - -const MixedExample = () => ( -
- -
- -
- -
- -
- -
- -
- -
- -
-); - -export { - DefaultExample, - WithHrefExample, - WithoutPaddingExample, - NonAtomicExample, - NonAtomicHrefExample, - DefaultDividedCardExample, - VerticalDividedCardExample, - WithHrefDividedCardExample, - NonElevatedDividedCardExample, - CardWrapperExample, - DividedCardWrapperExample, - WithClassNameWrapperExample, - MixedExample, -}; diff --git a/examples/bpk-component-card/stories.js b/examples/bpk-component-card/stories.js deleted file mode 100644 index 97f7ab69ae..0000000000 --- a/examples/bpk-component-card/stories.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2016 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import BpkCard from '../../packages/bpk-component-card/src/BpkCard'; -import BpkCardWrapper from '../../packages/bpk-component-card/src/BpkCardWrapper'; -import BpkDividedCard from '../../packages/bpk-component-card/src/BpkDividedCard'; - -import { - DefaultExample, - WithHrefExample, - WithoutPaddingExample, - NonAtomicExample, - NonAtomicHrefExample, - DefaultDividedCardExample, - VerticalDividedCardExample, - WithHrefDividedCardExample, - NonElevatedDividedCardExample, - CardWrapperExample, - DividedCardWrapperExample, - WithClassNameWrapperExample, - MixedExample, -} from './examples'; - -export default { - title: 'bpk-component-card', - component: BpkCard, - subcomponents: { - BpkDividedCard, - BpkCardWrapper, - }, -}; - -export const Default = DefaultExample; -export const WithHref = WithHrefExample; - -export const WithoutPadding = WithoutPaddingExample; - -export const NonAtomic = NonAtomicExample; - -export const NonAtomicWithHref = NonAtomicHrefExample; - -export const DefaultDividedCard = DefaultDividedCardExample; -export const VerticalDividedCard = VerticalDividedCardExample; -export const WithHrefDividedCard = WithHrefDividedCardExample; -export const NonElevatedDividedCard = NonElevatedDividedCardExample; - -export const CardWrapper = CardWrapperExample; -export const DividedCardWrapper = DividedCardWrapperExample; -export const WithClassNameWrapper = WithClassNameWrapperExample; - -export const VisualTest = MixedExample; -export const VisualTestWithZoom = VisualTest.bind({}); -VisualTestWithZoom.args = { - zoomEnabled: true -}; \ No newline at end of file diff --git a/packages/.npmignore b/packages/.npmignore index 25bf1363ee..e0226ad067 100644 --- a/packages/.npmignore +++ b/packages/.npmignore @@ -1,7 +1,17 @@ bpk-component-boilerplate bpk-storybook-utils *-test.js +*-test.tsx +*.test.js +*.test.tsx stories.js +stories.tsx +*.stories.js +*.stories.jsx +*.stories.ts +*.stories.tsx +*.stories.module.scss +*.stories.module.css __snapshots__ docs tasks diff --git a/examples/bpk-component-badge/BpkBadgeLayout.module.scss b/packages/bpk-component-badge/src/BpkBadge.stories.module.scss similarity index 91% rename from examples/bpk-component-badge/BpkBadgeLayout.module.scss rename to packages/bpk-component-badge/src/BpkBadge.stories.module.scss index 102d056ac4..87faa70c6e 100644 --- a/examples/bpk-component-badge/BpkBadgeLayout.module.scss +++ b/packages/bpk-component-badge/src/BpkBadge.stories.module.scss @@ -16,8 +16,8 @@ * limitations under the License. */ -@use '../../packages/bpk-mixins/tokens'; -@use '../../packages/bpk-mixins/radii'; +@use '../../bpk-mixins/tokens'; +@use '../../bpk-mixins/radii'; .bpk-badge-layout { &__container { diff --git a/examples/bpk-component-badge/examples.tsx b/packages/bpk-component-badge/src/BpkBadge.stories.tsx similarity index 76% rename from examples/bpk-component-badge/examples.tsx rename to packages/bpk-component-badge/src/BpkBadge.stories.tsx index 40292e82a4..a163766cf6 100644 --- a/examples/bpk-component-badge/examples.tsx +++ b/packages/bpk-component-badge/src/BpkBadge.stories.tsx @@ -16,6 +16,8 @@ * limitations under the License. */ +import type { ReactNode } from 'react'; + import { coreAccentDay, coreEcoDay, @@ -31,16 +33,36 @@ import { statusWarningSpotDay, } from '@skyscanner/bpk-foundations-web/tokens/base.es6'; -import BpkBadge, { BADGE_TYPES } from '../../packages/bpk-component-badge'; -import BpkSmallExclamationIcon from '../../packages/bpk-component-icon/sm/exclamation'; -import BpkSmallHelpCircleIcon from '../../packages/bpk-component-icon/sm/help-circle'; -import BpkSmallTickIcon from '../../packages/bpk-component-icon/sm/tick-circle'; // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`. -import BpkThemeProvider from '../../packages/bpk-theming'; +import { BpkDarkExampleWrapper } from '../../../examples/bpk-storybook-utils'; +import BpkSmallExclamationIcon from '../../bpk-component-icon/sm/exclamation'; +import BpkSmallHelpCircleIcon from '../../bpk-component-icon/sm/help-circle'; +import BpkSmallTickIcon from '../../bpk-component-icon/sm/tick-circle'; +import { cssModules } from '../../bpk-react-utils'; // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`. -import { BpkDarkExampleWrapper } from '../bpk-storybook-utils'; +import BpkThemeProvider from '../../bpk-theming'; + +import BpkBadge, { BADGE_TYPES } from './BpkBadge'; + +import type { Meta } from '@storybook/react'; -import BadgeLayout from './BadgeLayout'; +import LAYOUT_STYLES from './BpkBadge.stories.module.scss'; + +const getClassName = cssModules(LAYOUT_STYLES); + +type BadgeLayoutProps = { + docked?: string | null; + children: ReactNode; +}; + +const BadgeLayout = ({ children, docked = null }: BadgeLayoutProps) => { + const classNames = getClassName( + 'bpk-badge-layout__container', + docked && 'bpk-badge-layout__container--light', + ); + + return
{children}
; +}; const DefaultExample = () => ( @@ -296,21 +318,81 @@ const MixedExample = () => ( ); -export { - DefaultExample, - WarningExample, - SuccessExample, - CriticalExample, - InverseExample, - OutlineExample, - StrongExample, - BrandExample, - CenteredExample, - DockedLeadingExample, - DockedTrailingExample, - MixedExample, - ThemedCornerRadiusExample, - ThemedBackgroundColorExample, - ThemedIconColorExample, - ThemedTypographyExample, +const meta = { + title: 'bpk-component-badge', + component: BpkBadge, +} satisfies Meta; + +export default meta; + + +export const Default = { + render: () => , +}; + +export const Warning = { + render: () => , +}; + +export const Success = { + render: () => , +}; + +export const Critical = { + render: () => , +}; + +export const Strong = { + render: () => , +}; + +export const Brand = { + render: () => , +}; + +export const Inverse = { + render: () => , +}; + +export const Outline = { + render: () => , +}; + +export const Centered = { + render: () => , +}; + +export const DockedRight = { + render: () => , +}; + +export const DockedLeft = { + render: () => , +}; + +export const ThemedCornerRadius = { + render: () => , +}; + +export const ThemedBackgroundColor = { + render: () => , +}; + +export const ThemedIconColor = { + render: () => , +}; + +export const ThemedTypography = { + render: () => , +}; + +export const VisualTest = { + render: () => , +}; + +export const VisualTestWithZoom = { + render: () => , + args: { + zoomEnabled: true, + }, }; diff --git a/examples/bpk-component-button/BpkButtonStory.module.scss b/packages/bpk-component-button/src/BpkButton.stories.module.scss similarity index 94% rename from examples/bpk-component-button/BpkButtonStory.module.scss rename to packages/bpk-component-button/src/BpkButton.stories.module.scss index 303ff7890a..6deeb82c1e 100644 --- a/examples/bpk-component-button/BpkButtonStory.module.scss +++ b/packages/bpk-component-button/src/BpkButton.stories.module.scss @@ -16,7 +16,7 @@ * limitations under the License. */ -@use '../../packages/bpk-mixins/tokens'; +@use '../../bpk-mixins/tokens'; .bpk-button-story-wrapper { padding: tokens.bpk-spacing-sm() 0; diff --git a/examples/bpk-component-button/examples.tsx b/packages/bpk-component-button/src/BpkButton.stories.tsx similarity index 87% rename from examples/bpk-component-button/examples.tsx rename to packages/bpk-component-button/src/BpkButton.stories.tsx index 3d358728d0..735be2f3e4 100644 --- a/examples/bpk-component-button/examples.tsx +++ b/packages/bpk-component-button/src/BpkButton.stories.tsx @@ -16,26 +16,28 @@ * limitations under the License. */ -import BpkButton, { - BUTTON_TYPES, - SIZE_TYPES, -} from '../../packages/bpk-component-button'; + +// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`. +import { action, BpkDarkExampleWrapper } from '../../../examples/bpk-storybook-utils'; import { withButtonAlignment, withLargeButtonAlignment, withRtlSupport, -} from '../../packages/bpk-component-icon'; -import LargeLightningIcon from '../../packages/bpk-component-icon/lg/lightning'; -import LargeLongArrowRightIcon from '../../packages/bpk-component-icon/lg/long-arrow-right'; -import SmallLightningIcon from '../../packages/bpk-component-icon/sm/lightning'; -import SmallLongArrowRightIcon from '../../packages/bpk-component-icon/sm/long-arrow-right'; -import { cssModules } from '../../packages/bpk-react-utils'; -// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`. -import BpkThemeProvider from '../../packages/bpk-theming'; +} from '../../bpk-component-icon'; +import LargeLightningIcon from '../../bpk-component-icon/lg/lightning'; +import LargeLongArrowRightIcon from '../../bpk-component-icon/lg/long-arrow-right'; +import SmallLightningIcon from '../../bpk-component-icon/sm/lightning'; +import SmallLongArrowRightIcon from '../../bpk-component-icon/sm/long-arrow-right'; +import { cssModules } from '../../bpk-react-utils'; // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`. -import { action, BpkDarkExampleWrapper } from '../bpk-storybook-utils'; +import BpkThemeProvider from '../../bpk-theming'; + +import BpkButton from './BpkButton'; +import { BUTTON_TYPES, SIZE_TYPES } from './common-types'; + +import type { Meta } from '@storybook/react'; -import STYLES from './BpkButtonStory.module.scss'; +import STYLES from './BpkButton.stories.module.scss'; const RtlSmallLongArrowRightIcon = withRtlSupport(SmallLongArrowRightIcon); const RtlLargeLongArrowRightIcon = withRtlSupport(LargeLongArrowRightIcon); @@ -54,7 +56,7 @@ type StoryProps = Omit[0], 'children'> & { wrapped: typeof BpkButton; }; -const ButtonStory = ({ className, wrapped, ...rest }: StoryProps) => { +const ButtonStory = ({ className = undefined, wrapped, ...rest }: StoryProps) => { const Wrapped = wrapped; return (
{ ); }; -ButtonStory.defaultProps = { className: null }; const PrimaryExample = (props: any) => ( @@ -487,20 +488,81 @@ const AnchorTagsExample = () => ( ); -export { - PrimaryExample, - PrimaryOnDarkExample, - PrimaryOnLightExample, - SecondaryExample, - SecondaryOnDarkExample, - DestructiveExample, - FeaturedExample, - LinkExample, - LinkOnDarkExample, - LinksExamples, - MixedExample, - AnchorTagsExample, - FullWidthExample, - SubmitButtonExample, - ThemedBorderRadiusExample, +const meta = { + title: 'bpk-component-button', + component: BpkButton, +} satisfies Meta; + +export default meta; + + +export const BpkButtonPrimary = { + render: () => , +}; + +export const BpkButtonPrimaryOnDark = { + render: () => , +}; + +export const BpkButtonPrimaryOnLight = { + render: () => , +}; + +export const BpkButtonSecondary = { + render: () => , +}; + +export const BpkButtonSecondaryOnDark = { + render: () => , +}; + +export const BpkButtonDestructive = { + render: () => , +}; + +export const BpkButtonFeatured = { + render: () => , +}; + +export const BpkButtonLinkButton = { + render: () => , +}; + +export const BpkButtonLinkOnDarkButton = { + render: () => , +}; + +export const BpkButtonLinks = { + render: () => , +}; + +export const Mixture = { + render: () => , +}; + +export const AnchorTags = { + render: () => , +}; + +export const VisualTest = { + render: () => , +}; + +export const VisualTestWithZoom = { + render: () => , + args: { + zoomEnabled: true, + }, +}; + +export const SubmitButton = { + render: () => , +}; + +export const FullWidth = { + render: () => , +}; + +export const ThemedCornerRadius = { + render: () => , }; diff --git a/examples/bpk-component-card/examples.module.scss b/packages/bpk-component-card/src/BpkCard.stories.module.scss similarity index 95% rename from examples/bpk-component-card/examples.module.scss rename to packages/bpk-component-card/src/BpkCard.stories.module.scss index 358bbe621f..edb9b3856b 100644 --- a/examples/bpk-component-card/examples.module.scss +++ b/packages/bpk-component-card/src/BpkCard.stories.module.scss @@ -16,7 +16,7 @@ * limitations under the License. */ -@use '../../packages/bpk-mixins/tokens'; +@use '../../bpk-mixins/tokens'; .bpk-card-examples { &__header { diff --git a/packages/bpk-component-card/src/BpkCard.stories.tsx b/packages/bpk-component-card/src/BpkCard.stories.tsx new file mode 100644 index 0000000000..a592f16fb3 --- /dev/null +++ b/packages/bpk-component-card/src/BpkCard.stories.tsx @@ -0,0 +1,302 @@ +/* + * Backpack - Skyscanner's Design System + * + * Copyright 2016 Skyscanner Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Fragment } from 'react'; + + +import { + coreAccentDay, + surfaceHighlightDay, +} from '@skyscanner/bpk-foundations-web/tokens/base.es6'; + +import BpkText, { TEXT_STYLES } from '../../bpk-component-text'; +import { cssModules } from '../../bpk-react-utils'; + +import BpkCard from './BpkCard'; +import BpkCardWrapper from './BpkCardWrapper'; +import BpkDividedCard, { ORIENTATION } from './BpkDividedCard'; + +import type { Meta } from '@storybook/react'; + +import STYLES from './BpkCard.stories.module.scss'; + +const getClassName = cssModules(STYLES); + +const shortContent = 'Book your next trip on skyscanner.net.'; +const longMessage = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sagittis sagittis purus, id +blandit ipsum. Pellentesque nec diam nec erat condimentum dapibus. Nunc diam augue, egestas id egestas ut, facilisis +nec mi. Donec et congue odio, nec laoreet est. Integer rhoncus varius arcu, a fringilla libero laoreet at. Mauris +porta varius ullamcorper. Sed laoreet libero mauris, non pretium lectus accumsan et. Suspendisse vehicula ullamcorper +sapien, et dapibus mi aliquet non. Pellentesque auctor sagittis lectus vitae rhoncus. Fusce id enim porttitor, mattis +ante in, vestibulum nulla.`; + +const headerContent = ( +
+ + Wrapper title + +
+); + +const longContent = ( + + + Let's explore + + + It's your world and we'll help you explore it. Find the best + prices across millions of flights, hotels and car hire options to create + your perfect trip. +
+
+
+); + +const meta = { + title: 'bpk-component-card', + component: BpkCard, + subcomponents: { + BpkDividedCard, + BpkCardWrapper, + }, +} satisfies Meta; + +export default meta; + + +export const Default = { + render: () => ( + window.open('https://www.skyscanner.net/')}> + {shortContent} + + ), +}; + +export const WithHref = { + render: () => ( + {shortContent} + ), +}; + +export const WithoutPadding = { + render: () => ( + window.open('https://www.skyscanner.net/')} + > + {shortContent} + + ), +}; + +export const NonAtomic = { + render: () => ( + window.open('https://www.skyscanner.net/')} + > + {longContent} + + ), +}; + +export const NonAtomicWithHref = { + render: () => ( + + {longContent} + + ), +}; + +export const DefaultDividedCard = { + render: () => ( + + ), +}; + +export const VerticalDividedCard = { + render: () => ( + + ), +}; + +export const WithHrefDividedCard = { + render: () => ( + + ), +}; + +export const NonElevatedDividedCard = { + render: () => ( + + ), +}; + +export const CardWrapper = { + render: () => ( + window.open('https://www.skyscanner.net/')} + > + {longContent} + + } + header={headerContent} + /> + ), +}; + +export const DividedCardWrapper = { + render: () => ( + + } + header={headerContent} + /> + ), +}; + +export const WithClassNameWrapper = { + render: () => ( + window.open('https://www.skyscanner.net/')} + > + {longContent} + + } + header={headerContent} + // eslint-disable-next-line @skyscanner/rules/forbid-component-props + className={getClassName('bpk-card-examples__wrapper')} + /> + ), +}; + +export const VisualTest = { + render: () => ( +
+ window.open('https://www.skyscanner.net/')}> + {shortContent} + +
+ window.open('https://www.skyscanner.net/')} + > + {shortContent} + +
+ +
+ +
+ +
+ window.open('https://www.skyscanner.net/')} + > + {longContent} + + } + header={headerContent} + /> +
+ + } + header={headerContent} + /> +
+ window.open('https://www.skyscanner.net/')} + > + {longContent} + + } + header={headerContent} + // eslint-disable-next-line @skyscanner/rules/forbid-component-props + className={getClassName('bpk-card-examples__wrapper')} + /> +
+ ), +}; + +export const VisualTestWithZoom = { + ...VisualTest, + args: { + zoomEnabled: true, + }, +}; diff --git a/scripts/scss/styles-prod.js b/scripts/scss/styles-prod.js index 736fa099a2..096423ac7e 100644 --- a/scripts/scss/styles-prod.js +++ b/scripts/scss/styles-prod.js @@ -26,7 +26,9 @@ const files = new Glob(DIR_GLOB, {}); try { for (const file of files) { - compile(file); + if (!file.includes('.stories.')) { + compile(file); + } } } catch (err) { // eslint-disable-next-line no-console