Skip to content

Commit

Permalink
feat: refactor color token structure with tier 3 tokens #296
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Jun 14, 2024
1 parent fa6f4c3 commit a1746ef
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 110 deletions.
31 changes: 27 additions & 4 deletions demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ For use cases where the field is `required`, but live validation is not wanted,
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>

### Error support and HTML5 Validity
## Error support and HTML5 Validity

The `<auro-input>` component follows the HTML5 input `validity` and `validityState` [specification](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#client-side_validation).

Expand Down Expand Up @@ -718,7 +718,7 @@ export function customError() {
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>

### Types
## Types

### Password

Expand Down Expand Up @@ -1076,7 +1076,7 @@ Use the `type="year-month-day"` attribute for a date formatted input.
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>

### Additional Use Cases
## Additional Use Cases

### Swapping Values Between Inputs

Expand Down Expand Up @@ -1158,4 +1158,27 @@ export function swapInputValues() {
}
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>
</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-input-alert-icon-color: var(--ds-color-alert-error-default, $ds-color-alert-error-default);
--ds-auro-input-background-color: var(--ds-color-background-primary-100-default, $ds-color-background-primary-100-default);
--ds-auro-input-border-color: var(--ds-color-border-secondary-default, $ds-color-border-secondary-default);
--ds-auro-input-caret-color: var(--ds-color-text-ui-focus-default, $ds-color-text-ui-focus-default);
--ds-auro-input-help-text-color: var(--ds-color-text-tertiary-default, $ds-color-text-tertiary-default);
--ds-auro-input-label-text-color: var(--ds-color-text-tertiary-default, $ds-color-text-tertiary-default);
--ds-auro-input-notification-icon-color: var(--ds-color-alert-error-default, $ds-color-alert-error-default);
--ds-auro-input-placeholder-text-color: transparent;
--ds-auro-input-text-color: var(--ds-color-text-primary-default, $ds-color-text-primary-default);
--ds-auro-input-type-icon-color: var(--ds-color-icon-primary-default, $ds-color-icon-primary-default);
}
```
<!-- AURO-GENERATED-CONTENT:END -->
13 changes: 10 additions & 3 deletions docs/partials/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ For use cases where the field is `required`, but live validation is not wanted,

</auro-accordion>

### Error support and HTML5 Validity
## Error support and HTML5 Validity

The `<auro-input>` component follows the HTML5 input `validity` and `validityState` [specification](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#client-side_validation).

Expand Down Expand Up @@ -367,7 +367,7 @@ Use the `error` attribute to apply a persistent custom error that supersedes the

</auro-accordion>

### Types
## Types

### Password

Expand Down Expand Up @@ -557,7 +557,7 @@ Use the `type="year-month-day"` attribute for a date formatted input.

</auro-accordion>

### Additional Use Cases
## Additional Use Cases

### Swapping Values Between Inputs

Expand All @@ -578,3 +578,10 @@ Example illustrates using a JavaScript function attached to an `auro-button` com
<!-- 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) -->
<!-- AURO-GENERATED-CONTENT:END -->
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"build:dev:assets": "npm-run-all build:sass:component postCss:component sass:render",
"build:docs": "node scripts/generateDocs.mjs",
"build:sass": "npm-run-all build:sass:component postCss:component sass:render",
"build:sass:component": "sass --no-source-map src/style.scss:src/style.css",
"build:sass:component": "for file in src/*.scss; do npx sass --no-source-map \"$file:${file%.scss}.css\"; done",
"build:watch": "nodemon -e scss,js --watch src --exec npm run build:dev:assets",
"bundler": "rollup -c",
"bundler:test": "rollup -c -w",
Expand Down
68 changes: 56 additions & 12 deletions scripts/postCss.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,62 @@
import autoprefixer from 'autoprefixer';
import postcss from 'postcss';
import comments from 'postcss-discard-comments';
import path from 'path';
import fs from 'fs';
const __dirname = new URL('.', import.meta.url).pathname;
const directoryPath = path.join(__dirname, '../src');

fs.readFile('src/style.css', (err, css) => {
postcss([autoprefixer, comments])
.use(comments({
remove: function(comment) { return comment[0] == "@"; }
}))
.process(css, { from: 'src/style.css', to: 'src/style.css' })
.then(result => {
fs.writeFile('src/style.css', result.css, () => true)
if ( result.map ) {
fs.writeFile('src/style.map', result.map, () => true)
}
})
/**
* Default postCSS run
* Locates all CSS files within the directory and loop
* through the standardProcessor() function.
*/
fs.readdir(directoryPath, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
//listing all files using forEach
files.forEach(function (file) {
if (file.includes(".css")) {
standardProcessor(file);
}
});
});

/**
* The standardProcessor function applies tokens for fallback selectors
* and completes a post cleanup.
* @param {string} file
*/
function standardProcessor(file) {
fs.readFile(`src/${file}`, (err, css) => {
postcss([autoprefixer, comments])
.use(comments({
remove: function(comment) { return comment[0] == "@"; }
}))
.process(css, { from: `src/${file}`, to: `src/${file}` })
.then(result => {
fs.writeFile(`src/${file}`, result.css, () => true)
})
});
}

/**
* ALTERNATE script:
* The following is a static builder for rendering one
* CSS file at a time if that is required.
*/
// fs.readFile('src/style.css', (err, css) => {
// postcss([autoprefixer, comments])
// .use(comments({
// remove: function(comment) { return comment[0] == "@"; }
// }))
// .process(css, { from: 'src/style.css', to: 'src/style.css' })
// .then(result => {
// fs.writeFile('src/style.css', result.css, () => true)
// if ( result.map ) {
// fs.writeFile('src/style.map', result.map, () => true)
// }
// })
// });
11 changes: 8 additions & 3 deletions src/base-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { LitElement, css } from "lit";
import { ifDefined } from 'lit/directives/if-defined.js';

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

import closelg from '@alaskaairux/icons/dist/icons/interface/x-sm.mjs';
import viewPassword from '@alaskaairux/icons/dist/icons/interface/view-password.mjs';
import hidePassword from '@alaskaairux/icons/dist/icons/interface/hide-password.mjs';
Expand Down Expand Up @@ -223,9 +226,11 @@ export default class BaseInput extends LitElement {
}

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

connectedCallback() {
Expand Down
103 changes: 103 additions & 0 deletions src/color.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// See LICENSE in the project root for license information.

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

// Support for fallback values
@import './../node_modules/@aurodesignsystem/design-tokens/dist/tokens/SCSSVariables.scss';

/* stylelint-disable no-descending-specificity */

// Handle highlighting the border during focus and invalid state
@mixin border-highlight {
&:before {
border-bottom-color: transparent;
}
}

.wrapper {
border-color: transparent;
}

.inputElement-helpText {
color: var(--ds-auro-input-help-text-color);
}

input {
background-color: transparent;
caret-color: var(--ds-auro-input-caret-color);
color: var(--ds-color-input-text-color);

&::placeholder {
color: var(--ds-auro-input-placeholder-text-color);
}

&:focus {
&::placeholder {
--ds-auro-input-placeholder-text-color: var(--ds-color-text-primary-default, #{$ds-color-text-primary-default});
}
}

&:disabled {
--ds-auro-input-input-text-color: var(--ds-color-text-disabled-default, #{$ds-color-text-disabled-default});
}
}

label {
color: var(--ds-auro-input-label-text-color);
}

.alertNotification {
color: var(--ds-auro-input-alert-icon-color);
}

.typeIcon {
color: var(--ds-auro-input-type-icon-color);
}

:host(:not([bordered], [borderless])) {
.wrapper {
border-bottom-color: var(--ds-auro-input-border-color);
}
}

:host([bordered]) {
.wrapper {
border-color: var(--ds-auro-input-border-color);
background-color: var(--ds-auro-input-background-color);

&:focus-within {
--ds-auro-input-border-color: var(--ds-color-border-ui-focus-default, #{$ds-color-border-ui-focus-default});

box-shadow: inset 0 0 0 1px var(--ds-auro-input-border-color);
}
}
}

:host(:not([borderless])) {
.wrapper {
&:focus-within {
--ds-auro-input-border-color: var(--ds-color-border-ui-focus-default, #{$ds-color-border-ui-focus-default});

@include border-highlight;
}
}
}

:host([validity]:not([validity='valid'])) {
--ds-auro-input-border-color: var(--ds-color-border-error-default, #{$ds-color-border-error-default});
--ds-auro-input-help-text-color: var(--ds-color-alert-error-default, #{$ds-color-alert-error-default});
}

:host([validity]:not([validity='valid'])[bordered]) {
.wrapper {
--ds-auro-input-border-color: var(--ds-color-border-error-default, #{$ds-color-border-error-default});

box-shadow: inset 0 0 0 1px var(--ds-auro-input-border-color);
}
}

:host([disabled]) {
--ds-auro-input-border-color: var(--ds-color-border-ui-disabled-default, #{$ds-color-border-ui-disabled-default});
--ds-auro-input-type-icon-color: var(--ds-color-text-disabled-default, #{$ds-color-text-disabled-default});
--ds-auro-input-label-text-color: var(--ds-color-text-disabled-default, #{$ds-color-text-disabled-default});
}
Loading

0 comments on commit a1746ef

Please sign in to comment.