diff --git a/packages/styles/src/molecules/index.css b/packages/styles/src/molecules/index.css index 9972ae6ae0..720fc83440 100644 --- a/packages/styles/src/molecules/index.css +++ b/packages/styles/src/molecules/index.css @@ -18,3 +18,4 @@ @import './radio-group.css'; @import './search-input.css'; @import './table.css'; +@import './product-title.css'; diff --git a/packages/styles/src/molecules/product-title.css b/packages/styles/src/molecules/product-title.css new file mode 100644 index 0000000000..0a4dc11065 --- /dev/null +++ b/packages/styles/src/molecules/product-title.css @@ -0,0 +1,23 @@ +[data-fs-product-title] { + width: fit-content; + background-color: #cecece; + padding: 8px; + border-radius: 5px; +} +[data-fs-product-title] [data-fs-product-title-header] { + display: flex; + column-gap: .75rem; + justify-content: space-between; +} +[data-fs-product-title] [data-fs-product-title-header]:first-child { + font-size: 20px; + font-weight: 400; + line-height: 1.12; +} +[data-fs-product-title] [data-fs-product-title-header] [data-store-badge] { + white-space: nowrap; +} +[data-fs-product-title] [data-fs-product-title-addendum] { + margin-top: 1rem; + color: #5d666f; +} \ No newline at end of file diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index 8f91d94521..c0f3106204 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -54,6 +54,9 @@ export { default as Incentive } from './atoms/Incentive' export type { IncentiveProps } from './atoms/Incentive' // Molecules +export { default as ProductTitle } from './molecules/ProductTitle' +export type { ProductTitleProps } from './molecules/ProductTitle' + export { default as AggregateRating } from './molecules/AggregateRating' export type { AggregateRatingProps } from './molecules/AggregateRating' diff --git a/packages/ui/src/molecules/ProductTitle/ProductTitle.tsx b/packages/ui/src/molecules/ProductTitle/ProductTitle.tsx new file mode 100644 index 0000000000..27f15f7988 --- /dev/null +++ b/packages/ui/src/molecules/ProductTitle/ProductTitle.tsx @@ -0,0 +1,44 @@ +import React, { HTMLAttributes } from 'react' +import type { ReactNode } from 'react' + +export type ProductTitleProps = Omit, 'title'> & { + /** + * A react component to be used as the product title, e.g. a `h1` + */ + title: ReactNode + /** + * A react component to be used as the product label, e.g. a `DiscountBadge` + */ + label?: ReactNode + /** + * Label for reference. + */ + refTag?: string + /** + * A text to be used below the title and the label, such as the product's reference number. + */ + refNumber?: string + /** + * ID to find this component in testing tools (e.g.: cypress, testing library, and jest). + */ + testId?: string +} + +function ProductTitle({ title, label, refTag= "Ref.: ",refNumber, testId= 'store-product-title', ...otherProps }: ProductTitleProps) { + return ( +
+
+ {title} + {!!label && label} +
+ + {refNumber && ( +

+ {refTag}{refNumber} +

+ )} +
+ ) +} + +export default ProductTitle diff --git a/packages/ui/src/molecules/ProductTitle/index.tsx b/packages/ui/src/molecules/ProductTitle/index.tsx new file mode 100644 index 0000000000..0b88c02740 --- /dev/null +++ b/packages/ui/src/molecules/ProductTitle/index.tsx @@ -0,0 +1,2 @@ +export { default } from './ProductTitle' +export type { ProductTitleProps } from './ProductTitle' diff --git a/packages/ui/src/molecules/ProductTitle/stories/ProductTitle.mdx b/packages/ui/src/molecules/ProductTitle/stories/ProductTitle.mdx new file mode 100644 index 0000000000..56a193ce01 --- /dev/null +++ b/packages/ui/src/molecules/ProductTitle/stories/ProductTitle.mdx @@ -0,0 +1,26 @@ +import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs' + +import ProductTitle from '../ProductTitle' + +# ProductTitle + + + + + +## Props + + + +## CSS Selectors + +```css +[data-fs-product-title] { +} + +[data-fs-product-title-header] { +} + +[data-fs-product-title-addendum] { +} +``` diff --git a/packages/ui/src/molecules/ProductTitle/stories/ProductTitle.stories.tsx b/packages/ui/src/molecules/ProductTitle/stories/ProductTitle.stories.tsx new file mode 100644 index 0000000000..907da067c8 --- /dev/null +++ b/packages/ui/src/molecules/ProductTitle/stories/ProductTitle.stories.tsx @@ -0,0 +1,27 @@ +import type { Story, Meta } from '@storybook/react' +import React from 'react' + +import type { ProductTitleProps } from '../ProductTitle' +import Component from '../ProductTitle' +import mdx from './ProductTitle.mdx' +import Badge from '../../../atoms/Badge' + +const ProductTitleTemplate: Story = () => ( + Apple Magic Mouse} + refNumber='99995945' + label={90%} + /> +) + +export const ProductTitle = ProductTitleTemplate.bind({}) +ProductTitle.storyName = 'ProductTitle' + +export default { + title: 'Molecules/ProductTitle', + parameters: { + docs: { + page: mdx, + }, + }, +} as Meta