generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typography component #17
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
46 changes: 46 additions & 0 deletions
46
apps/frontend/src/components/Typography/Heading.stories.ts
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,46 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Heading } from './Typography'; | ||
|
||
const meta = { | ||
title: 'Heading', | ||
component: Heading, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof Heading>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const H1: Story = { | ||
args: { | ||
level: 'h1', | ||
children: 'Heading h1', | ||
}, | ||
}; | ||
export const H2: Story = { | ||
args: { | ||
level: 'h2', | ||
children: 'Heading h2', | ||
}, | ||
}; | ||
export const H3: Story = { | ||
args: { | ||
level: 'h3', | ||
children: 'Heading h3', | ||
}, | ||
}; | ||
export const H4: Story = { | ||
args: { | ||
level: 'h4', | ||
children: 'Heading h4', | ||
}, | ||
}; | ||
export const H5: Story = { | ||
args: { | ||
level: 'h5', | ||
children: 'Heading h5', | ||
}, | ||
}; |
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,22 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Text } from './Typography'; | ||
|
||
const meta = { | ||
title: 'Text', | ||
component: Text, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof Text>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Paragraphs: Story = { | ||
args: { | ||
children: | ||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean dapibus vehicula tincidunt. Mauris vel dui purus. Vestibulum ultricies egestas scelerisque. Proin venenatis consequat pellentesque. Nunc porttitor vestibulum velit. Nunc nec eros sit amet nibh luctus mattis. Nulla facilisi. Aenean euismod purus mi, et tincidunt velit auctor vitae', | ||
}, | ||
}; |
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,51 @@ | ||
import clsx from 'clsx'; | ||
|
||
export interface HeadingProps { | ||
level: 'h1' | 'h2' | 'h3' | 'h4' | 'h5'; | ||
children: React.ReactNode; | ||
} | ||
const common = 'font-gellix'; | ||
const h1 = 'text-6xl font-semibold leading-[4.25rem]'; | ||
const h2 = 'text-5xl font-semibold leading-[3.5rem]'; | ||
const h3 = 'text-4xl font-semibold leading-[2.75rem]'; | ||
const h4 = 'text-3xl font-light'; | ||
const h5 = 'text-2xl'; | ||
|
||
export const Heading = ({ level, children }: HeadingProps) => { | ||
const Tag = level; | ||
|
||
return ( | ||
<Tag | ||
className={clsx(common, { | ||
[h1]: level === 'h1', | ||
[h2]: level === 'h2', | ||
[h3]: level === 'h3', | ||
[h4]: level === 'h4', | ||
[h5]: level === 'h5', | ||
})} | ||
> | ||
{children} | ||
</Tag> | ||
); | ||
}; | ||
|
||
export interface TextProps { | ||
size?: 'default' | 'small' | 'tiny'; | ||
weight?: 'regular' | 'bold'; | ||
children: React.ReactNode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
} | ||
|
||
export const Text = ({ size = 'default', weight = 'regular', children }: TextProps) => { | ||
return ( | ||
<p | ||
className={clsx(common, { | ||
'font-semibold': weight === 'bold', | ||
'text-xl leading-6': size === 'default', | ||
'text-sm leading-5': size === 'small', | ||
'text-xs leading-4': size === 'tiny', | ||
})} | ||
> | ||
{children} | ||
</p> | ||
); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property
children
refers multiple elements but it can be defined astext
and the type can be string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm thinking that if we need to add, for example, a
span
tag around some of the text for whatever reason, this can be done. Plus it simulates the original heading and paragraph tags