-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref #555 #107 Implemented icon button according new design, added hover and disabled states for non-default variant. Migrated text toolbar from toggle group to icon button. Toggle between superscript and subscript. <img width="285" alt="image" src="https://user-images.githubusercontent.com/5635476/206522786-28cc6b7d-6336-4c13-8eb7-b83428598dcb.png"> <img width="315" alt="image" src="https://user-images.githubusercontent.com/5635476/206523165-1b4a080d-0c8d-41a1-b5a9-47c197b78998.png"> <img width="197" alt="image" src="https://user-images.githubusercontent.com/5635476/206521819-14c1fbb3-6c37-4264-8f7b-cef256b4ab23.png">
- Loading branch information
Showing
9 changed files
with
241 additions
and
94 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
46 changes: 46 additions & 0 deletions
46
packages/design-system/src/components/icon-button.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { ComponentStory } from "@storybook/react"; | ||
import { CrossIcon } from "@webstudio-is/icons"; | ||
import { Flex } from "./flex"; | ||
import { IconButton } from "./icon-button"; | ||
|
||
export default { | ||
component: IconButton, | ||
}; | ||
|
||
export const Default: ComponentStory<typeof IconButton> = () => { | ||
return ( | ||
<Flex direction="column" gap={2}> | ||
<Flex gap={2}> | ||
<IconButton> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="preset"> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="set"> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="inherited"> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="active"> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
</Flex> | ||
<Flex gap={2}> | ||
<IconButton disabled={true}> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="preset" disabled={true}> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="set" disabled={true}> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
<IconButton variant="inherited" disabled={true}> | ||
<CrossIcon fill="currentColor" /> | ||
</IconButton> | ||
</Flex> | ||
</Flex> | ||
); | ||
}; |
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,86 @@ | ||
import { styled } from "../stitches.config"; | ||
|
||
export const IconButton = styled("button", { | ||
// reset styles | ||
boxSizing: "border-box", | ||
padding: 0, | ||
appearance: "none", | ||
backgroundColor: "transparent", | ||
border: "1px solid transparent", | ||
// center icon | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
// prevent shrinking inside flex box | ||
flexShrink: 0, | ||
// set size and shape | ||
width: 28, | ||
height: 28, | ||
borderRadius: "$borderRadius$3", | ||
|
||
"&:focus-visible": { | ||
outline: "2px solid $blue10", | ||
}, | ||
"&:disabled": { | ||
borderColor: "transparent", | ||
pointerEvents: "none", | ||
}, | ||
|
||
variants: { | ||
variant: { | ||
default: { | ||
color: "$slate12", | ||
"&:hover": { | ||
backgroundColor: "$slate6", | ||
}, | ||
"&:disabled": { | ||
color: "$slate8", | ||
}, | ||
}, | ||
preset: { | ||
backgroundColor: "$slate6", | ||
borderColor: "$slate8", | ||
color: "$slate12", | ||
"&:hover": { | ||
backgroundColor: "$slate8", | ||
}, | ||
"&:disabled": { | ||
color: "$slate8", | ||
}, | ||
}, | ||
set: { | ||
backgroundColor: "$blue4", | ||
borderColor: "$blue6", | ||
color: "$blue11", | ||
"&:hover": { | ||
backgroundColor: "$blue6", | ||
}, | ||
"&:disabled": { | ||
color: "$blue6", | ||
}, | ||
}, | ||
inherited: { | ||
backgroundColor: "$orange4", | ||
borderColor: "$orange6", | ||
color: "$orange11", | ||
"&:hover": { | ||
backgroundColor: "$orange6", | ||
}, | ||
"&:disabled": { | ||
color: "$orange6", | ||
}, | ||
}, | ||
active: { | ||
backgroundColor: "$blue10", | ||
color: "White", | ||
// non-interactive state because usually covered with overlay | ||
}, | ||
}, | ||
}, | ||
|
||
defaultVariants: { | ||
variant: "default", | ||
}, | ||
}); | ||
|
||
IconButton.displayName = "IconButton"; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.