generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Adding react Text component to design-system-react #110
Open
georgewrmarshall
wants to merge
11
commits into
main
Choose a base branch
from
fix/react-text
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ac49ed6
chore: fixing body lg size
georgewrmarshall 2b3cfc4
fix: font weight
georgewrmarshall b13974e
chore: storybook clean up
georgewrmarshall 6db7bc9
chore: removing dependency for storybook manager
georgewrmarshall a458e1f
chore: updating vite config
georgewrmarshall 0a41489
chore: lint fix
georgewrmarshall a307ad0
feat: initial text component
georgewrmarshall 53a2748
chore: fixing exports of types
georgewrmarshall 7634cee
chore: improving comments for tailwind merge
georgewrmarshall 2c7a07e
chore: updating yarn.lock
georgewrmarshall b9c3685
Merge branch 'main' into fix/react-text
brianacnguyen 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
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 |
---|---|---|
|
@@ -46,6 +46,9 @@ | |
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose", | ||
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch" | ||
}, | ||
"dependencies": { | ||
"tailwind-merge": "^2.0.0" | ||
}, | ||
Comment on lines
+49
to
+51
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. Tailwind merge is what portfolio uses to resolve tailwind classname conflicts and duplicates |
||
"devDependencies": { | ||
"@metamask/auto-changelog": "^3.4.4", | ||
"@metamask/design-system-tailwind-preset": "workspace:^", | ||
|
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
222 changes: 222 additions & 0 deletions
222
packages/design-system-react/src/components/text/README.mdx
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,222 @@ | ||
import { Controls, Canvas } from '@storybook/blocks'; | ||
|
||
import * as TextStories from './Text.stories'; | ||
|
||
# Text | ||
|
||
Text is the used to render text and paragraphs within an interface | ||
|
||
<Canvas of={TextStories.Default} /> | ||
|
||
## Props | ||
|
||
### Variant | ||
|
||
Use the `variant` prop and the `TextVariant` enum from `@metamask/design-system-react` to change the font size of the component. The `Text` component uses responsive font sizes. | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Variant</th> | ||
<th>Small Screen</th> | ||
<th>Large Screen (tailwind prefix md:)</th> | ||
<th>Default HTML Tag</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>DisplayLg</td> | ||
<td>2.5rem (40px)</td> | ||
<td>4rem (64px)</td> | ||
<td> | ||
<code>h1</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>DisplayMd</td> | ||
<td>2rem (32px)</td> | ||
<td>3rem (48px)</td> | ||
<td> | ||
<code>h1</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>HeadingLg</td> | ||
<td>1.5rem (24px)</td> | ||
<td>2rem (32px)</td> | ||
<td> | ||
<code>h2</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>HeadingMd</td> | ||
<td>1.125rem (18px)</td> | ||
<td>1.5rem (24px)</td> | ||
<td> | ||
<code>h3</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>HeadingSm</td> | ||
<td>1rem (16px)</td> | ||
<td>1.125rem (18px)</td> | ||
<td> | ||
<code>h4</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>BodyLg</td> | ||
<td>1rem (16px)</td> | ||
<td>1.125rem (18px)</td> | ||
<td> | ||
<code>p</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>BodyMd</td> | ||
<td>0.875rem (14px)</td> | ||
<td>1rem (16px)</td> | ||
<td> | ||
<code>p</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>BodySm</td> | ||
<td>0.75rem (12px)</td> | ||
<td>0.875rem (14px)</td> | ||
<td> | ||
<code>p</code> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>BodyXs</td> | ||
<td>0.625rem (10px)</td> | ||
<td>0.75rem (12px)</td> | ||
<td> | ||
<code>p</code> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<Canvas of={TextStories.Variant} /> | ||
|
||
### Color | ||
|
||
Use the `color` prop and the `TextColor` enum from `@metamask/design-system-react` to change the color of the `Text` component. | ||
|
||
<Canvas of={TextStories.Color} /> | ||
|
||
### Font Weight | ||
|
||
Use the `fontWeight` prop and the `FontWeight` enum from `@metamask/design-system-react` to change the font weight of the `Text` component. | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Font Weight</th> | ||
<th>CSS Value</th> | ||
<th>Weight Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<code>FontWeight.Normal</code> | ||
</td> | ||
<td> | ||
<code>normal</code> | ||
</td> | ||
<td>400</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<code>FontWeight.Medium</code> | ||
</td> | ||
<td> | ||
<code>medium</code> | ||
</td> | ||
<td>500</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<code>FontWeight.Bold</code> | ||
</td> | ||
<td> | ||
<code>bold</code> | ||
</td> | ||
<td>700</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<Canvas of={TextStories.FontWeightStory} /> | ||
|
||
### Font Style | ||
|
||
Use the `fontStyle` prop and the `FontStyle` enum from `@metamask/design-system-react` to change the font style of the `Text` component. There are 2 font styles: | ||
|
||
- `FontStyle.Normal` | ||
- `FontStyle.Italic` | ||
|
||
<Canvas of={TextStories.FontStyleStory} /> | ||
|
||
### Text Transform | ||
|
||
Use the `textTransform` prop and the `TextTransform` enum from `@metamask/design-system-react` to change the text transformation of the `Text` component. | ||
|
||
<Canvas of={TextStories.TextTransformStory} /> | ||
|
||
### Text Align | ||
|
||
Use the `textAlign` prop and the `TextAlign` enum from `@metamask/design-system-react` to change the text alignment of the `Text` component. | ||
|
||
<Canvas of={TextStories.TextAlignStory} /> | ||
|
||
### Overflow Wrap | ||
|
||
Use the `overflowWrap` prop and the `OverflowWrap` enum from `@metamask/design-system-react` to change the overflow wrap of the `Text` component. | ||
|
||
<Canvas of={TextStories.OverflowWrapStory} /> | ||
|
||
### Ellipsis | ||
|
||
Use the boolean `ellipsis` prop to make the `Text` component have an ellipsis. | ||
|
||
<Canvas of={TextStories.Ellipsis} /> | ||
|
||
### As | ||
|
||
Use the `as` prop to change the root HTML element of the `Text` component. | ||
|
||
You can also utilize the `ValidTag` enum from `@metamask/design-system-react` to ensure that you are using a valid HTML element. | ||
|
||
<Canvas of={TextStories.As} /> | ||
|
||
Renders the HTML: | ||
|
||
```html | ||
<span>span</span> <strong>strong</strong> | ||
``` | ||
|
||
### Strong | ||
|
||
Using the `as` prop with the value of `strong` will render the `Text` component as a `strong` element and any `strong` elements used within a `Text` component will be supported with bold styles. | ||
|
||
<Canvas of={TextStories.Strong} /> | ||
|
||
### Class Name | ||
|
||
Adds an additional class to the `Text` component. | ||
|
||
### Children | ||
|
||
The text content of the `Text` component. | ||
|
||
### Component API | ||
|
||
<Controls of={TextStories.Default} /> | ||
|
||
### References | ||
|
||
[MetaMask Design System Guides](https://www.notion.so/MetaMask-Design-System-Guides-Design-f86ecc914d6b4eb6873a122b83c12940) |
Oops, something went wrong.
Oops, something went wrong.
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.
Ignores the types for the mdx file. Not that this effects tests but will make it cleaner