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

Feature/cta tokens #96

Merged
merged 5 commits into from
Dec 10, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions packages/library/components/cta/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:host {
display: inline-block;
user-select: none;
font-family: "Open Sans Bold", sans-serif;
font-family: $CTA_FONT_FAMILY;

/**
* Styles specifically for the `<a>` element.
Expand All @@ -24,63 +24,64 @@
font-size: inherit;
font-weight: inherit;
line-height: inherit;

&::-moz-focus-inner {
border: 0;
}
}

& .cta {
display: flex;
flex-direction: row;
align-items: center;
text-align: start;
column-gap: 1rem;
padding-top: 0.5rem;
padding-right: 1rem;
padding-bottom: 0.5rem;
padding-left: 1rem;
background-color: #333;
color: #fff;
padding-block-start: 0.5rem;
padding-block-end: 0.5rem;
padding-inline-start: 1rem;
padding-inline-end: 1rem;
background-color: $CTA_DEFAULT_BACKGROUND_COLOR;
color: $CTA_DEFAULT_COLOR;
border-color: $CTA_DEFAULT_BORDER_COLOR;
border-width: 2px;
border-style: solid;
border-color: #333;
border-radius: 10px;

&:hover {
background-color: #000;
border-color: #000;
background-color: $CTA_HOVER_BACKGROUND_COLOR;
border-color: $CTA_HOVER_BORDER_COLOR;
text-decoration: underline;
}

&:focus {
outline-color: #644bed;
& :focus:not(:focus-visible) {
outline: none; /* https://matthiasott.com/notes/focus-visible-is-here and https://www.tpgi.com/focus-visible-and-backwards-compatibility/ */
}

&:focus-visible {
outline-color: $CTA_FOCUS_OUTLINE_COLOR;
outline-offset: 0; /* Chrome by default adds a 1px offset on the `<a>` */
outline-style: solid;
outline-width: 3px;
text-decoration: underline;
}

&:active {
background-color: #644bed;
border-color: #644bed;
background-color: $CTA_ACTIVE_BACKGROUND_COLOR;
border-color: $CTA_ACTIVE_BORDER_COLOR;
}

&[disabled],
&.disabled {
background-color: #ccc;
border-color: #ccc;
background-color: $CTA_DISABLED_BACKGROUND_COLOR;
border-color: $CTA_DISABLED_BORDER_COLOR;
pointer-events: none;
}

&.loading {
background-color: #000;
border-color: #000;
background-color: $CTA_LOADING_BACKGROUND_COLOR;
border-color: $CTA_LOADING_BORDER_COLOR;
pointer-events: none;
}

& .label-holder {
min-width: 10em;
max-width: 32em;
min-inline-size: 10em;
max-inline-size: 32em;
}

& .icon {
Expand All @@ -90,6 +91,8 @@
}
}

/* TODO: move these `[disabled]` and `[loading]` styles to default.css */

/* stylelint-disable no-descending-specificity */
:host([disabled]),
:host([loading]) {
Expand Down
80 changes: 80 additions & 0 deletions packages/library/components/cta/src/token.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,110 @@
{
"cta": {
"type": {
"description": "Write description.",
"value": "standard",
"type": "string"
},
"loading": {
"message": {
"description": "Write description.",
"value": "Loading...",
"type": "string"
},
"icon": {
"name": {
"description": "Write description.",
"value": "spinner",
"type": "string"
}
},
"background": {
"color": {
"value": "{ colour.black.value }"
}
},
"border": {
"color": {
"value": "{ colour.black.value }"
}
}
},
"icon": {
"name": {
"description": "Write description.",
"value": "arrow-right",
"type": "string"
},
"position": {
"description": "Write description.",
"value": "end",
"type": "string"
}
},
"font": {
"family": {
"description": "Write description.",
"value": "{ asset.font.bold.name.value }"
}
},
"default": {
"color": {
"value": "{ colour.white.value }"
},
"background": {
"color": {
"value": "{ colour.grey.darkest.value }"
}
},
"border": {
"color": {
"value": "{ colour.grey.darkest.value }"
}
}
},
"hover": {
"background": {
"color": {
"value": "{ colour.black.value }"
}
},
"border": {
"color": {
"value": "{ colour.black.value }"
}
}
},
"focus": {
"outline": {
"color": {
"value": "{ colour.focus.value }"
}
}
},
"active": {
"background": {
"color": {
"value": "{ colour.primary.value }"
}
},
"border": {
"color": {
"value": "{ colour.primary.value }"
}
}
},
"disabled": {
"background": {
"color": {
"value": "{ colour.grey.light.value }"
}
},
"border": {
"color": {
"value": "{ colour.grey.light.value }"
}
}

}
}
}
24 changes: 12 additions & 12 deletions packages/library/components/cta/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ Loading.args = { text: 'Highpoint', loading: true };

export const StandardLink = (args) => details.template(args, (args) => args.text);
StandardLink.storyName = 'Standard [link]';
StandardLink.args = { text: 'Highpoint', href: 'https://duckduckgo.com' };
StandardLink.args = { text: 'Highpoint', href: '#!' };

export const DisabledLink = (args) => details.template(args, (args) => args.text);
DisabledLink.storyName = 'Disabled [link]';
DisabledLink.args = { text: 'Highpoint', disabled: true, href: 'https://duckduckgo.com' };
DisabledLink.args = { text: 'Highpoint', disabled: true, href: '#!' };

export const HiddenLink = (args) => details.template(args, (args) => args.text);
HiddenLink.storyName = 'hidden [link]';
HiddenLink.args = { text: 'Highpoint', hidden: true, href: 'https://duckduckgo.com' };
HiddenLink.args = { text: 'Highpoint', hidden: true, href: '#!' };

export const LoadingLink = (args) => details.template(args, (args) => args.text);
LoadingLink.storyName = 'Loading [link]';
LoadingLink.args = { text: 'Highpoint', loading: true, href: 'https://duckduckgo.com' };
LoadingLink.args = { text: 'Highpoint', loading: true, href: '#!' };

const btnEnable = `
<script>
Expand Down Expand Up @@ -75,32 +75,32 @@ LoadingForm.args = { text: 'Highpoint', loading: true };

export const StandardWithinLink = (args) => `<a href="${args.link}">${details.template(args, (args) => args.text)}</a>`;
StandardWithinLink.storyName = 'Standard [within link]';
StandardWithinLink.args = { text: 'Highpoint', link: 'https://duckduckgo.com' };
StandardWithinLink.args = { text: 'Highpoint', link: '#!' };

export const DisabledWithinLink = (args) => `<a href="${args.link}">${details.template(args, (args) => args.text)}</a>`;
DisabledWithinLink.storyName = 'Disabled [within link]';
DisabledWithinLink.args = { text: 'Highpoint', disabled: true, link: 'https://duckduckgo.com' };
DisabledWithinLink.args = { text: 'Highpoint', disabled: true, link: '#!' };

export const HiddenWithinLink = (args) => `<a href="${args.link}">${details.template(args, (args) => args.text)}</a>`;
HiddenWithinLink.storyName = 'Hidden [within link]';
HiddenWithinLink.args = { text: 'Highpoint', hidden: true, link: 'https://duckduckgo.com' };
HiddenWithinLink.args = { text: 'Highpoint', hidden: true, link: '#!' };

export const LoadingWithinLink = (args) => `<a href="${args.link}">${details.template(args, (args) => args.text)}</a>`;
LoadingWithinLink.storyName = 'Loading [within link]';
LoadingWithinLink.args = { text: 'Highpoint', loading: true, link: 'https://duckduckgo.com' };
LoadingWithinLink.args = { text: 'Highpoint', loading: true, link: '#!' };

export const StandardWithinButton = (args) => `<button>${details.template(args, (args) => args.text)}</button>`;
StandardWithinButton.storyName = 'Standard [within button]';
StandardWithinButton.args = { text: 'Highpoint', link: 'https://duckduckgo.com' };
StandardWithinButton.args = { text: 'Highpoint', link: '#!' };

export const DisabledWithinButton = (args) => `<button disabled>${details.template(args, (args) => args.text)}</button>`;
DisabledWithinButton.storyName = 'Disabled [within button]';
DisabledWithinButton.args = { text: 'Highpoint', disabled: true, link: 'https://duckduckgo.com' };
DisabledWithinButton.args = { text: 'Highpoint', disabled: true, link: '#!' };

export const HiddenWithinButton = (args) => `<button hidden>${details.template(args, (args) => args.text)}</button>`;
HiddenWithinButton.storyName = 'Hidden [within button]';
HiddenWithinButton.args = { text: 'Highpoint', hidden: true, link: 'https://duckduckgo.com' };
HiddenWithinButton.args = { text: 'Highpoint', hidden: true, link: '#!' };

export const LoadingWithinButton = (args) => `<button>${details.template(args, (args) => args.text)}</button>`;
LoadingWithinButton.storyName = 'Loading [within button]';
LoadingWithinButton.args = { text: 'Highpoint', loading: true, link: 'https://duckduckgo.com' };
LoadingWithinButton.args = { text: 'Highpoint', loading: true, link: '#!' };
27 changes: 24 additions & 3 deletions packages/library/tokens/default/colour.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
{
"colour": {
"white": {
"value": "#FAFAFA"
"value": "#fff"
},
"black": {
"value": "#212121"
"value": "#000"
},
"primary": {
"value": "#644bed"
},
"grey": {
"lightest": {
"value": "#eee"
},
"light": {
"value": "#ccc"
},
"mid": {
"value": "#999"
},
"dark": {
"value": "#666"
},
"darkest": {
"value": "#333"
},
"1": {
"value": "#F5F5F5"
},
Expand All @@ -32,8 +50,11 @@
"value": "#424242"
}
},
"focus": {
"value": "#b2a1fb"
},
"action": {
"value": "#2962FF"
"value": "#2962ff"
},
"error": {
"value": "#d32f2f"
Expand Down