Skip to content
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

[@mantine/core]: Fix disabled gradient styles for Button and ActionIcon. #2277

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
100 changes: 91 additions & 9 deletions src/mantine-core/src/ActionIcon/ActionIcon.story.tsx
Expand Up @@ -16,15 +16,97 @@ export function AsLink() {
);
}

export function Disabled() {
export function States() {
const theme = useMantineTheme();

const sharedStyles: CSSProperties = {
padding: '10px 20px',
border: `1px solid ${
theme.colorScheme === 'light' ? theme.colors.gray[1] : theme.colors.dark[6]
}`,
};

const states = [
{
name: 'enabled',
props: undefined,
},
{
name: 'disabled',
props: {
disabled: true,
},
},
{
name: 'loading',
props: {
loading: true,
},
},
];

return (
<div style={{ padding: 40 }}>
<ActionIcon disabled variant="transparent">
$
</ActionIcon>
<ActionIcon loading color="blue">
$
</ActionIcon>
<div
style={{
padding: '40px',
}}
>
<table
style={{
borderCollapse: 'collapse',
}}
>
<thead>
<tr>
<th
style={{
...sharedStyles,
}}
>
&nbsp;
</th>

{ACTION_ICON_VARIANTS.map((variant) => (
<th
key={variant}
style={{
...sharedStyles,
}}
>
{variant}
</th>
))}
</tr>
</thead>
<tbody>
{states.map((state) => (
<tr key={state.name}>
<td
style={{
...sharedStyles,
}}
>
{state.name}
</td>

{ACTION_ICON_VARIANTS.map((variant) => (
<td
key={variant}
style={{
...sharedStyles,
}}
>
<Center>
<ActionIcon variant={variant} color="blue" {...state.props}>
#
</ActionIcon>
</Center>
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
);
}
Expand Down Expand Up @@ -65,7 +147,7 @@ export function Colors() {
...sharedStyles,
}}
>
color
&nbsp;
</th>

{ACTION_ICON_VARIANTS.map((variant) => (
Expand Down
1 change: 1 addition & 0 deletions src/mantine-core/src/ActionIcon/ActionIcon.styles.ts
Expand Up @@ -103,6 +103,7 @@ export default createStyles(
variant === 'transparent'
? undefined
: theme.fn.themeColor('gray', theme.colorScheme === 'dark' ? 8 : 1),
backgroundImage: 'none',

'&:active': {
transform: 'none',
Expand Down
102 changes: 95 additions & 7 deletions src/mantine-core/src/Button/Button.story.tsx
@@ -1,8 +1,10 @@
import React from 'react';
import { MANTINE_COLORS } from '@mantine/styles';
import React, { CSSProperties } from 'react';
import { MANTINE_COLORS, useMantineTheme } from '@mantine/styles';
import { IconExternalLink } from '@tabler/icons';
import { Button } from './Button';
import { Group } from '../Group';
import { Center } from '../Center';
import { BUTTON_VARIANTS } from './Button.styles';

export default { title: 'Button' };

Expand Down Expand Up @@ -31,12 +33,98 @@ export function Colors() {
return <div style={{ padding: 40, backgroundColor: 'rgba(0,0,0,0.1)' }}>{items}</div>;
}

export function Disabled() {
export function States() {
const theme = useMantineTheme();

const sharedStyles: CSSProperties = {
padding: '10px 20px',
border: `1px solid ${
theme.colorScheme === 'light' ? theme.colors.gray[1] : theme.colors.dark[6]
}`,
};

const states = [
{
name: 'enabled',
props: undefined,
},
{
name: 'disabled',
props: {
disabled: true,
},
},
{
name: 'loading',
props: {
loading: true,
},
},
];

return (
<Group p={40}>
<Button disabled>Disabled</Button>
<Button loading>Loading</Button>
</Group>
<div
style={{
padding: '40px',
}}
>
<table
style={{
borderCollapse: 'collapse',
}}
>
<thead>
<tr>
<th
style={{
...sharedStyles,
}}
>
&nbsp;
</th>

{BUTTON_VARIANTS.map((variant) => (
<th
key={variant}
style={{
...sharedStyles,
}}
>
{variant}
</th>
))}
</tr>
</thead>
<tbody>
{states.map((state) => (
<tr key={state.name}>
<td
style={{
...sharedStyles,
}}
>
{state.name}
</td>

{BUTTON_VARIANTS.map((variant) => (
<td
key={variant}
style={{
...sharedStyles,
}}
>
<Center>
<Button variant={variant} {...state.props}>
{state.name}
</Button>
</Center>
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
);
}

Expand Down
20 changes: 12 additions & 8 deletions src/mantine-core/src/Button/Button.styles.ts
Expand Up @@ -9,14 +9,17 @@ import {
} from '@mantine/styles';
import { INPUT_SIZES } from '../Input';

export type ButtonVariant =
| 'filled'
| 'outline'
| 'light'
| 'gradient'
| 'white'
| 'default'
| 'subtle';
export const BUTTON_VARIANTS = [
'filled',
'outline',
'light',
'white',
'default',
'subtle',
'gradient',
] as const;

export type ButtonVariant = typeof BUTTON_VARIANTS[number];

export interface ButtonStylesParams {
color: MantineColor;
Expand Down Expand Up @@ -137,6 +140,7 @@ export default createStyles(
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2],
color: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[5],
cursor: 'not-allowed',
backgroundImage: 'none',

'&:active': {
transform: 'none',
Expand Down