Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 37 additions & 21 deletions frontends/ol-components/src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const meta: Meta<typeof Button> = {
control: { type: "select" },
},
edge: {
options: ["circular", "rounded", "none"],
options: ["circular", "rounded"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edge="none" is not in figma; it was added for resource cards, but that is handled a little differently now (changed in #1180 )

control: { type: "select" },
},
startIcon: {
Expand Down Expand Up @@ -247,29 +247,40 @@ export const LinkStory: Story = {
}
export const ButtonsShowcase: Story = {
render: (args) => (
<Grid container rowGap={2} sx={{ maxWidth: "500px" }}>
<Grid container rowGap={2} sx={{ maxWidth: "600px" }}>
{VARIANTS.flatMap((variant) =>
EDGES.flatMap((edge) =>
EXTRA_PROPS.map((extraProps, i) => {
return SIZES.map((size) => (
<Grid
item
xs={4}
display="flex"
alignItems="center"
key={`${variant}-${edge}-${size}-${i}`}
>
<Button
{...args}
variant={variant}
edge={edge}
size={size}
{...extraProps}
>
{args.children}
</Button>
</Grid>
))
return (
<React.Fragment key={`${variant}-${edge}-${i}`}>
<Grid xs={3}>
<pre>
variant={variant}
<br />
edge={edge}
</pre>
</Grid>
{SIZES.map((size) => (
<Grid
item
xs={3}
display="flex"
alignItems="center"
key={`${size}`}
>
<Button
{...args}
variant={variant}
edge={edge}
size={size}
{...extraProps}
>
{args.children}
</Button>
</Grid>
))}
</React.Fragment>
)
}),
),
)}
Expand Down Expand Up @@ -321,6 +332,11 @@ export const ActionButtonsShowcase: Story = {
alignItems="center"
sx={{ my: 2 }}
>
<pre>
variant={variant}
<br />
edge={edge}
</pre>
{SIZES.map((size) => (
<React.Fragment key={size}>
{ICONS.map((icon) => (
Expand Down
19 changes: 9 additions & 10 deletions frontends/ol-components/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ButtonStyled = styled.button<ButtonStyleProps>((props) => {
...props,
}
const { colors } = theme.custom
const hasBorder = variant === "secondary" || variant === "text"
const hasBorder = variant === "secondary"

return [
{
Expand Down Expand Up @@ -110,17 +110,22 @@ const ButtonStyled = styled.button<ButtonStyleProps>((props) => {
backgroundColor: colors.mitRed,
color: colors.white,
border: "none",
/* Shadow/04dp */
boxShadow:
"0px 2px 4px 0px rgba(37, 38, 43, 0.10), 0px 3px 8px 0px rgba(37, 38, 43, 0.12)",
":hover:not(:disabled)": {
backgroundColor: colors.red,
boxShadow: "none",
},
":disabled": {
backgroundColor: colors.silverGray,
boxShadow: "none",
},
},
hasBorder && {
backgroundColor: "transparent",
borderColor: "currentcolor",
borderStyle: variant === "secondary" ? "solid" : "none",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, const hasBorder = variant === "secondary" || variant === "text". But that was weird because text variant doesn't actually have a border. It was just set that way to pick up backgroundColor: transparent.

Applying backgroundColor: transparent to the text variant separately is simpler / more understandable, imo.

borderStyle: "solid",
},
variant === "secondary" && {
color: colors.red,
Expand All @@ -132,6 +137,8 @@ const ButtonStyled = styled.button<ButtonStyleProps>((props) => {
},
},
variant === "text" && {
backgroundColor: "transparent",
borderStyle: "none",
color: colors.darkGray2,
":hover:not(:disabled)": {
backgroundColor: tinycolor(colors.darkGray1).setAlpha(0.06).toString(),
Expand Down Expand Up @@ -177,14 +184,6 @@ const ButtonStyled = styled.button<ButtonStyleProps>((props) => {
// Pill-shaped buttons... Overlapping border radius get clipped to pill.
borderRadius: "100vh",
},
edge === "none" && {
border: "none",
":hover:not(:disabled)": {
"&&": {
backgroundColor: "inherit",
},
},
},
// color
color === "secondary" && {
color: theme.custom.colors.silverGray,
Expand Down