Skip to content

Commit

Permalink
refactor: use consistent disabled styles from theme mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
abelflopes committed Jul 11, 2024
1 parent fa6b827 commit 5644211
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ $padding: theme.get-spacing(4);
}

.disabled {
cursor: not-allowed;
filter: grayscale(1);
opacity: 0.4;
@include theme.disabled;
}

// Variations
Expand Down Expand Up @@ -73,7 +71,7 @@ $padding: theme.get-spacing(4);
}

.disabled .file {
cursor: not-allowed;
@include theme.disabled;
}

.button {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
@import "@react-ck/theme";
@import "@react-ck/text";
@use "@react-ck/theme";
@use "@react-ck/text";

.root {
@include text-base;
@include text.text-base;

display: flex;
box-sizing: border-box;
align-items: center;
padding: get-spacing(0.75) get-spacing();
border-radius: get-spacing();
padding: theme.get-spacing(0.75) theme.get-spacing();
border-radius: theme.get-spacing();
cursor: pointer;
gap: get-spacing();
gap: theme.get-spacing();
transition: all 0.2s;

&:focus:not(.disabled),
&:hover:not(.disabled) {
background-color: get-color(neutral-light-2);
background-color: theme.get-color(neutral-light-2);
color: currentcolor;
}

&.secondary {
background-color: get-color(neutral-light-1-5);
background-color: theme.get-color(neutral-light-1-5);
}

&.primary {
background-color: get-color(highlight-primary-light);
color: get-color(highlight-primary);
background-color: theme.get-color(highlight-primary-light);
color: theme.get-color(highlight-primary);
}

&.disabled {
// TODO: create shared mixin
cursor: not-allowed;
filter: grayscale(1);
opacity: 0.4;
@include theme.disabled;
}

&.horizontal {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/button/src/styles/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
transition: background-color 0.2s ease;

&:disabled {
cursor: not-allowed;
@include theme.disabled;
}

&.icon-only {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/form-field/src/styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}

&:disabled {
cursor: not-allowed;
@include theme.disabled;
}

&:focus {
Expand Down
7 changes: 7 additions & 0 deletions packages/docs/stories/src/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ export const Link: Story = {
as: ["a", { href: "/" }],
},
};

export const Disabled: Story = {
args: {
...Primary.args,
disabled: true,
},
};
1 change: 1 addition & 0 deletions packages/docs/stories/src/dock.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const footer = (
<IconUserCircle />
</Icon>
}
disabled
/>
</>
);
Expand Down
5 changes: 5 additions & 0 deletions packages/providers/theme/src/styles/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@mixin disabled {
cursor: not-allowed;
filter: grayscale(1);
opacity: 0.4;
}
1 change: 1 addition & 0 deletions packages/providers/theme/src/styles/shared.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import "functions";
@import "mixins";

0 comments on commit 5644211

Please sign in to comment.