-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Wrapping long text in Button components (#24682)
* fix: Wrapping long text in Button components. * Adding change file. * Adding vr tests and replacing min-height in buttons with padding+border+line-height calculation. * Removing uneeded text-overflow style. * Adding long text to long text vr stories and replacing 'truncate' with 'wrap' in storybook stories. * Adding long text to long text vr stories. Co-authored-by: KHMakoto <humberto_makoto@hotmail.com>
- Loading branch information
Showing
8 changed files
with
269 additions
and
88 deletions.
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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-button-2d7b0be2-d4e1-469e-8bf8-032018a98cfb.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix: Wrapping long text in Button components.", | ||
"packageName": "@fluentui/react-button", | ||
"email": "humberto_makoto@hotmail.com", | ||
"dependentChangeType": "patch" | ||
} |
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
27 changes: 19 additions & 8 deletions
27
packages/react-components/react-button/src/stories/Button/ButtonWithLongText.stories.tsx
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 |
---|---|---|
@@ -1,16 +1,27 @@ | ||
import * as React from 'react'; | ||
import { Button } from '@fluentui/react-components'; | ||
import { makeStyles, Button } from '@fluentui/react-components'; | ||
|
||
const useStyles = makeStyles({ | ||
longText: { | ||
width: '280px', | ||
}, | ||
}); | ||
|
||
export const WithLongText = () => { | ||
const styles = useStyles(); | ||
|
||
return ( | ||
<> | ||
<Button>Short text</Button> | ||
<Button className={styles.longText}>Long text wraps after it hits the max width of the component</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export const WithLongText = () => ( | ||
<> | ||
<Button>Short text</Button> | ||
<Button>Long text truncates after it hits the max width of the component</Button> | ||
</> | ||
); | ||
WithLongText.parameters = { | ||
docs: { | ||
description: { | ||
story: 'Text truncates after it hits the max width of the component.', | ||
story: 'Text wraps after it hits the max width of the component.', | ||
}, | ||
}, | ||
}; |
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
69 changes: 41 additions & 28 deletions
69
...s/react-components/react-button/src/stories/MenuButton/MenuButtonWithLongText.stories.tsx
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 |
---|---|---|
@@ -1,39 +1,52 @@ | ||
import * as React from 'react'; | ||
import { Menu, MenuButton, MenuItem, MenuList, MenuPopover, MenuTrigger } from '@fluentui/react-components'; | ||
import { makeStyles, Menu, MenuButton, MenuItem, MenuList, MenuPopover, MenuTrigger } from '@fluentui/react-components'; | ||
|
||
export const WithLongText = () => ( | ||
<> | ||
<Menu> | ||
<MenuTrigger> | ||
<MenuButton>Short text</MenuButton> | ||
</MenuTrigger> | ||
const useStyles = makeStyles({ | ||
longText: { | ||
width: '280px', | ||
}, | ||
}); | ||
|
||
export const WithLongText = () => { | ||
const styles = useStyles(); | ||
|
||
return ( | ||
<> | ||
<Menu> | ||
<MenuTrigger> | ||
<MenuButton>Short text</MenuButton> | ||
</MenuTrigger> | ||
|
||
<MenuPopover> | ||
<MenuList> | ||
<MenuItem>Item a</MenuItem> | ||
<MenuItem>Item b</MenuItem> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
<MenuPopover> | ||
<MenuList> | ||
<MenuItem>Item a</MenuItem> | ||
<MenuItem>Item b</MenuItem> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
|
||
<Menu> | ||
<MenuTrigger> | ||
<MenuButton>Long text truncates after it hits the max width of the component</MenuButton> | ||
</MenuTrigger> | ||
<Menu> | ||
<MenuTrigger> | ||
<MenuButton className={styles.longText}> | ||
Long text wraps after it hits the max width of the component | ||
</MenuButton> | ||
</MenuTrigger> | ||
|
||
<MenuPopover> | ||
<MenuList> | ||
<MenuItem>Item a</MenuItem> | ||
<MenuItem>Item b</MenuItem> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
</> | ||
); | ||
}; | ||
|
||
<MenuPopover> | ||
<MenuList> | ||
<MenuItem>Item a</MenuItem> | ||
<MenuItem>Item b</MenuItem> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
</> | ||
); | ||
WithLongText.parameters = { | ||
docs: { | ||
description: { | ||
story: 'Text truncates after it hits the max width of the component.', | ||
story: 'Text wraps after it hits the max width of the component.', | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.