Skip to content

Commit

Permalink
refactor(button): use accent as the default
Browse files Browse the repository at this point in the history
Use accent styles for the default button when there is no variant class
applied, to match the default defined on the guidelines.

Also moves a few of the default color custom properties, so the colors
are all grouped together.
  • Loading branch information
jawinn committed Mar 28, 2024
1 parent ce3bee4 commit 6fad36a
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions components/button/index.css
Expand Up @@ -12,7 +12,6 @@ governing permissions and limitations under the License.

@import "@spectrum-css/commons/basebutton.css";

/* default for all buttons */
.spectrum-Button {
--spectrum-button-animation-duration: var(--spectrum-animation-duration-100);

Expand Down Expand Up @@ -40,15 +39,6 @@ governing permissions and limitations under the License.
--spectrum-button-top-to-icon: var(--spectrum-component-top-to-workflow-icon-100);
--spectrum-button-intended-icon-size: var(--spectrum-workflow-icon-size-100);

--spectrum-button-border-color-default: transparent;
--spectrum-button-border-color-hover: transparent;
--spectrum-button-border-color-down: transparent;
--spectrum-button-border-color-focus: transparent;

--spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color);
--spectrum-button-border-color-disabled: transparent;
--spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color);

--mod-progress-circle-position: absolute;
/* stylelint-disable-next-line spectrum-tools/no-unknown-custom-properties */
--spectrum-downstate-perspective: max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down));
Expand Down Expand Up @@ -130,15 +120,21 @@ governing permissions and limitations under the License.
--spectrum-button-intended-icon-size: var(--spectrum-workflow-icon-size-300);
}

/* Variant colors */
/* Variants and colors */
.spectrum-Button {
&.spectrum-Button--accent,
&.spectrum-Button--negative {
--spectrum-button-content-color-default: var(--spectrum-white);
--spectrum-button-content-color-hover: var(--spectrum-white);
--spectrum-button-content-color-down: var(--spectrum-white);
--spectrum-button-content-color-focus: var(--spectrum-white);
}
--spectrum-button-content-color-default: var(--spectrum-white);
--spectrum-button-content-color-hover: var(--spectrum-white);
--spectrum-button-content-color-down: var(--spectrum-white);
--spectrum-button-content-color-focus: var(--spectrum-white);

--spectrum-button-border-color-default: transparent;
--spectrum-button-border-color-hover: transparent;
--spectrum-button-border-color-down: transparent;
--spectrum-button-border-color-focus: transparent;

--spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color);
--spectrum-button-border-color-disabled: transparent;
--spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color);

&.spectrum-Button--outline {
--spectrum-button-background-color-disabled: transparent;
Expand All @@ -147,7 +143,9 @@ governing permissions and limitations under the License.
}

/* ---- Accent ---- */
&.spectrum-Button--accent {
/* Also shows as the default when a variant class is not used. */
&.spectrum-Button--accent,
& {
--spectrum-button-background-color-default: var(--spectrum-accent-background-color-default);
--spectrum-button-background-color-hover: var(--spectrum-accent-background-color-hover);
--spectrum-button-background-color-down: var(--spectrum-accent-background-color-down);
Expand All @@ -163,9 +161,7 @@ governing permissions and limitations under the License.
}

/* ---- Primary ---- */
/* Also shows as the default when a variant is not set. */
&.spectrum-Button--primary,
& {
&.spectrum-Button--primary {
--spectrum-button-background-color-default: var(--spectrum-neutral-background-color-default);
--spectrum-button-background-color-hover: var(--spectrum-neutral-background-color-hover);
--spectrum-button-background-color-down: var(--spectrum-neutral-background-color-down);
Expand Down Expand Up @@ -609,7 +605,14 @@ a.spectrum-Button {
}
}

&.spectrum-Button--accent {
&.spectrum-Button--accent,
&:not(
.spectrum-Button--primary,
.spectrum-Button--negative,
.spectrum-Button--secondary,
.spectrum-Button--staticBlack,
.spectrum-Button--staticWhite
){
/* The accent fill variant looks different than the other buttons.
It inverts the background and content colors. */
--highcontrast-button-background-color-default: ButtonText;
Expand Down

0 comments on commit 6fad36a

Please sign in to comment.