From b6cf6c50671b1be076500a874288147edd45f53c Mon Sep 17 00:00:00 2001 From: aymerick Date: Tue, 12 Nov 2024 14:10:48 +0100 Subject: [PATCH] fix card --- apps/doc/src/@crossed-ui/Card.stories.tsx | 41 +++++++++++++++++++++++ packages/ui/src/display/Card.tsx | 30 +++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 apps/doc/src/@crossed-ui/Card.stories.tsx diff --git a/apps/doc/src/@crossed-ui/Card.stories.tsx b/apps/doc/src/@crossed-ui/Card.stories.tsx new file mode 100644 index 00000000..4b44529d --- /dev/null +++ b/apps/doc/src/@crossed-ui/Card.stories.tsx @@ -0,0 +1,41 @@ +/** + * Copyright (c) Paymium. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root of this projects source tree. + */ + +import type { Meta, StoryObj } from '@storybook/react'; + +import { Card } from '@crossed/ui/src/display/Card'; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta: Meta = { + component: Card, + subcomponents: { + 'Card.Description': Card.Description, + 'Card.Extra': Card.Extra, + 'Card.Title': Card.Title, + }, + tags: ['autodocs'], + parameters: { layout: 'centered' }, + render: (e) => ( + + This is a title + This is the Description of your card + This is a litle extra + + ), +}; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const Primary: Story = { + parameters: { + docs: { + source: { language: 'tsx' }, + }, + }, +}; diff --git a/packages/ui/src/display/Card.tsx b/packages/ui/src/display/Card.tsx index d00fc9c9..e9b8125a 100644 --- a/packages/ui/src/display/Card.tsx +++ b/packages/ui/src/display/Card.tsx @@ -21,6 +21,11 @@ const useCard = createStyles(({ space, font, components }) => ({ borderColor: components.Card.default.border, gap: space.xxs, }, + media: { + xs: { padding: space.xs, gap: space.xxs }, + md: { padding: space.sm, gap: space.xs }, + xl: { padding: space.md, gap: space.sm }, + }, }, rootLink: { 'web': { base: { transition: 'all 0.27s ease' } }, @@ -35,12 +40,20 @@ const useCard = createStyles(({ space, font, components }) => ({ base: { color: components.Card.default.title, alignSelf: 'stretch', - fontSize: font.fontSize.lg, + fontSize: font.fontSize.xl, + fontWeight: font.fontWeight.h1, + lineHeight: font.lineHeight.xl, }, }, description: { base: { alignSelf: 'stretch', color: components.Card.default.description }, }, + extra: { + base: { + color: components.Card.default.description, + fontWeight: font.fontWeight.xl, + }, + }, })); type CardProps = YBoxProps; @@ -79,20 +92,33 @@ const Description = (props: TextProps) => { ); }; + +const Extra = (props: TextProps) => { + return ; +}; + const Card = withStaticProperties(CardRoot, { Title, Description, + Extra, }); -const { Title: CardTitle, Description: CardDescription } = Card; +const { + Title: CardTitle, + Description: CardDescription, + Extra: CardExtra, +} = Card; type CardTitleProps = GetProps; type CardDescriptionProps = GetProps; +type CardExtraProps = GetProps; export { Card, CardTitle, CardDescription, + CardExtra, type CardProps, type CardTitleProps, type CardDescriptionProps, + type CardExtraProps, };