Skip to content

Commit

Permalink
feat: refactor hard coded size values with tokens #198
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Jun 4, 2024
1 parent 4009ac7 commit 0bb579a
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 25 deletions.
17 changes: 17 additions & 0 deletions demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,3 +732,20 @@ export function auroMenuResetExample() {
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>

### Theme Support

The component may be restyled using the following code sample and changing the values of the following token(s).

<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../src/tokens.scss) -->
<!-- The below code snippet is automatically added from ./../../src/tokens.scss -->

```scss
:host {
--ds-auro-menu-border-color: var(--ds-color-border-divider-default, $ds-color-border-divider-default);
--ds-auro-menuoption-text-color: var(--ds-color-text-primary-default, $ds-color-text-primary-default);
--ds-auro-menuoption-icon-color: var(--ds-color-icon-emphasis-inverse, $ds-color-icon-emphasis-inverse);
--ds-auro-menuoption-background-color: transparent;
}
```
<!-- AURO-GENERATED-CONTENT:END -->
7 changes: 7 additions & 0 deletions docs/partials/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,10 @@ The `auro-menu` may be reset to a state with no menuoption selected by setting t

</auro-accordion>

### Theme Support

The component may be restyled using the following code sample and changing the values of the following token(s).

<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../src/tokens.scss) -->
<!-- AURO-GENERATED-CONTENT:END -->

10 changes: 9 additions & 1 deletion src/auro-menuoption.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

// ---------------------------------------------------------------------
import { LitElement, html } from "lit";

import styleCss from "./style-menuoption-css.js";
import colorCss from "./color-css.js";
import tokensCss from "./tokens-css.js";

import check from '@alaskaairux/icons/dist/icons/interface/check-sm_es6';

/**
Expand Down Expand Up @@ -66,7 +70,11 @@ class AuroMenuOption extends LitElement {
}

static get styles() {
return [styleCss];
return [
styleCss,
colorCss,
tokensCss
];
}

firstUpdated() {
Expand Down
31 changes: 31 additions & 0 deletions src/color.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
// See LICENSE in the project root for license information.

// ---------------------------------------------------------------------

/* stylelint-disable custom-property-empty-line-before, declaration-no-important */

@import './../node_modules/@aurodesignsystem/design-tokens/dist/tokens/SCSSVariables';

:host {
background-color: var(--ds-auro-menuoption-background-color);
color: var(--ds-auro-menuoption-text-color);
}

:host([disabled]) {
--ds-auro-menuoption-text-color: var(--ds-color-text-ui-disabled-default, $ds-color-text-ui-disabled-default);
}

:host(:hover:not([disabled])),
:host(.active:not([disabled])) {
--ds-auro-menuoption-background-color: var(--ds-color-container-ui-secondary-hover-default, #{$ds-color-container-ui-secondary-hover-default});
}

:host([selected]:not([disabled])) {
--ds-auro-menuoption-background-color: var(--ds-color-container-ui-primary-default-default, $ds-color-container-ui-primary-default-default);
--ds-auro-menuoption-text-color: var(--ds-color-text-primary-inverse, $ds-color-text-primary-inverse);

svg {
fill: var(--ds-auro-menuoption-icon-color) !important;
}
}
2 changes: 1 addition & 1 deletion src/style-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
margin: var(--ds-size-100, $ds-size-100) 0 !important;

border-width: 0 !important;
border-top: 1px solid var(--ds-color-border-divider-default, $ds-color-border-divider-default) !important;
border-top: 1px solid var(--ds-auro-menu-border-color) !important;
}
}

Expand Down
23 changes: 0 additions & 23 deletions src/style-menuoption.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
svg {
margin-right: var(--ds-size-150, $ds-size-150);
margin-left: var(--ds-size-100, $ds-size-100);

fill: var(--ds-color-icon-primary-default, $ds-color-icon-primary-default) !important;
}

::slotted(.nestingSpacer) {
Expand All @@ -65,26 +63,5 @@
}

:host([disabled]) {
color: var(--ds-color-text-disabled-default, $ds-color-text-disabled-default);

user-select: none;
}

:host(:hover:not([disabled])),
:host(.active:not([disabled])) {
background-color: var(--ds-color-ui-bkg-hover-default, $ds-color-ui-bkg-hover-default);
color: var(--ds-color-text-primary-default, $ds-color-text-primary-default);

svg {
fill: var(--ds-color-icon-primary-default, $ds-color-icon-primary-default) !important;
}
}

:host([selected]:not([disabled])) {
background-color: var(--ds-color-alert-notification-default, $ds-color-alert-notification-default);
color: var(--ds-color-base-white, $ds-color-base-white);

svg {
fill: var(--ds-color-base-white, $ds-color-base-white) !important;
}
}
6 changes: 6 additions & 0 deletions src/tokens.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:host {
--ds-auro-menu-border-color: var(--ds-color-border-divider-default, $ds-color-border-divider-default);
--ds-auro-menuoption-text-color: var(--ds-color-text-primary-default, $ds-color-text-primary-default);
--ds-auro-menuoption-icon-color: var(--ds-color-icon-emphasis-inverse, $ds-color-icon-emphasis-inverse);
--ds-auro-menuoption-background-color: transparent;
}

0 comments on commit 0bb579a

Please sign in to comment.