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

feat(Tokens): add extended palette color and update declarative colors #67

Merged
merged 24 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fe91d03
feat(colors): add extended primitive palette colors
dgonzalezr Mar 9, 2023
b6422b8
feat(Tailwind CSS): add extended color tokens in `tailwind.config.js`
dgonzalezr Mar 9, 2023
09064cb
fix(Colors): decouple netral and grey colors
dgonzalezr Mar 9, 2023
37fdfbc
feat(Colors): add declarative color tokens value
dgonzalezr Mar 15, 2023
ca1b216
refactor(Avatar): use the new palette color
dgonzalezr Mar 15, 2023
e2f624e
fix(Colors: add missing text-inverse token value
dgonzalezr Mar 15, 2023
91a07aa
fix(Colors): css names typo and use `active` instead of `selected`
dgonzalezr Mar 16, 2023
dea8c3d
refactor(Badge): use the new palette color
dgonzalezr Mar 16, 2023
e7274f4
refactor(Button): use the new paletter color
dgonzalezr Mar 16, 2023
509a19d
refactor(Checkbox): use the new palette color
dgonzalezr Mar 16, 2023
a66c956
refactor(Divider): use the new palette color
dgonzalezr Mar 16, 2023
4410d54
refactor(Radio): use the new palette color
dgonzalezr Mar 16, 2023
55997a5
refactor(Spinner): use the new palette color
dgonzalezr Mar 16, 2023
33b21ea
refactor(Status): use the new palette color and `bq-bagde` under the …
dgonzalezr Mar 16, 2023
f173e28
fix: sonarlint issues
dgonzalezr Mar 16, 2023
8f2fbbe
refactor(Switch): use the new palette color
dgonzalezr Mar 16, 2023
281b674
refactor(Slider): use the new palette color
dgonzalezr Mar 16, 2023
fbeb20e
fix(sonarlint): reduce sanitizePropValue() cognitive complexity
dgonzalezr Mar 16, 2023
8cb2277
test(Status): update invalid status type e2e test
dgonzalezr Mar 16, 2023
babb79c
fix(Volta): pin `node` and `npm` to latest LTS
dgonzalezr Mar 16, 2023
585cab1
feat(focus): add global components `.focus` state class
dgonzalezr Mar 17, 2023
bd8920c
fix: focus ring over background transparent
dgonzalezr Mar 17, 2023
adf7150
revert: button `link` styles
dgonzalezr Mar 20, 2023
cc32aa5
feat: add global `.link` style for `<a>` element
dgonzalezr Mar 20, 2023
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
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"root": true,
"plugins": ["@nrwl/nx"],
"parserOptions": {
"ecmaVersion": 2019
},
"overrides": [
{
"files": "*.json",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"jest-config": "$jest"
},
"volta": {
"node": "18.14.0",
"npm": "9.3.1"
"node": "18.15.0",
"npm": "9.5.0"
}
}
12 changes: 10 additions & 2 deletions packages/bee-q/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export namespace Components {
*/
"type": TButtonType;
/**
* The variant of button to apply on top of the appearance
* The variant of button to apply on top of the appearance (applicable only to `appearance="primary"`)
*/
"variant": TButtonVariant;
}
Expand Down Expand Up @@ -260,6 +260,10 @@ export namespace Components {
"value": string;
}
interface BqRadioGroup {
/**
* If true, all radio inputs in the group will display a background on hover
*/
"backgroundOnHover"?: boolean;
/**
* A number representing the delay time (in milliseconds) that `bqChange` event handler gets triggered once the value change
*/
Expand Down Expand Up @@ -668,7 +672,7 @@ declare namespace LocalJSX {
*/
"type"?: TButtonType;
/**
* The variant of button to apply on top of the appearance
* The variant of button to apply on top of the appearance (applicable only to `appearance="primary"`)
*/
"variant"?: TButtonVariant;
}
Expand Down Expand Up @@ -828,6 +832,10 @@ declare namespace LocalJSX {
"value": string;
}
interface BqRadioGroup {
/**
* If true, all radio inputs in the group will display a background on hover
*/
"backgroundOnHover"?: boolean;
/**
* A number representing the delay time (in milliseconds) that `bqChange` event handler gets triggered once the value change
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/bee-q/src/components/avatar/bq-avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class BqAvatar {
return (
<div
class={{
'relative overflow-hidden bg-ui-secondary': true,
'relative overflow-hidden bg-ui-secondary-light': true,
[`size--${this.size}`]: true,
'rounded-full': this.shape === 'circle',
'rounded-xs': this.shape === 'square' && this.size === 'xsmall',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ Number.args = { content: '12' };

export const Green = Template.bind({});
Green.args = {
'background-color': 'data--green',
'background-color': 'ui--success',
size: 'large',
};
2 changes: 1 addition & 1 deletion packages/bee-q/src/components/badge/bq-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class BqBadge {
// ========================

/** Badge background color. The value should be a valid value of the palette color */
@Prop({ mutable: true, reflect: true }) backgroundColor? = 'data--red';
@Prop({ mutable: true, reflect: true }) backgroundColor? = 'ui--danger';

/** Badge number color. The value should be a valid value of the palette color */
@Prop({ mutable: true, reflect: true }) textColor? = 'text--inverse';
Expand Down
15 changes: 14 additions & 1 deletion packages/bee-q/src/components/badge/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------ | ------------------------------------------------------------------------------ | --------------------- | ----------------- |
| `backgroundColor` | `background-color` | Badge background color. The value should be a valid value of the palette color | `string` | `'data--red'` |
| `backgroundColor` | `background-color` | Badge background color. The value should be a valid value of the palette color | `string` | `'ui--danger'` |
| `size` | `size` | The size of the badge | `"medium" \| "small"` | `'small'` |
| `textColor` | `text-color` | Badge number color. The value should be a valid value of the palette color | `string` | `'text--inverse'` |

Expand All @@ -22,6 +22,19 @@
| `"number"` | The component's internal wrapper that holds the slot. |


## Dependencies

### Used by

- [bq-status](../status)

### Graph
```mermaid
graph TD;
bq-status --> bq-badge
style bq-badge fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
2 changes: 1 addition & 1 deletion packages/bee-q/src/components/badge/scss/bq-badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

.bq-badge {
@apply flex items-center justify-center rounded-xl bg-[color:var(--bq-badge--background-color)] text-[color:var(--bq-badge--text-color)];
@apply flex items-center justify-center rounded-xl border-[1px] border-solid border-stroke-primary bg-[color:var(--bq-badge--background-color)] text-[color:var(--bq-badge--text-color)];
}

.size {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
--bq-badge--size-small: 8px;
--bq-badge--size-medium: 12px;
--bq-badge--size-large: 16px;
--bq-badge--background-color: theme('colors.data.red');
--bq-badge--background-color: theme('colors.ui.danger');
--bq-badge--text-color: theme('colors.text.inverse');
}
4 changes: 2 additions & 2 deletions packages/bee-q/src/components/button/bq-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class BqButton {
/** The default behavior of the button */
@Prop({ reflect: true }) type: TButtonType = 'button';

/** The variant of button to apply on top of the appearance */
/** The variant of button to apply on top of the appearance (applicable only to `appearance="primary"`) */
@Prop({ reflect: true }) variant: TButtonVariant = 'standard';

// Prop lifecycle events
Expand Down Expand Up @@ -194,7 +194,7 @@ export class BqButton {
rel={isLink && this.target ? 'noreferrer noopener' : undefined}
target={isLink ? this.target : undefined}
type={this.type}
tabIndex={0}
tabIndex={this.disabled ? -1 : 0}
onBlur={this.handleBlur}
onFocus={this.handleFocus}
onClick={this.handleClick}
Expand Down
2 changes: 1 addition & 1 deletion packages/bee-q/src/components/button/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Buttons are designed for users to take action on a page or a screen.
| `size` | `size` | The size of the button | `"large" \| "medium" \| "small"` | `'medium'` |
| `target` | `target` | Where to display the linked URL, as the name for a browsing context (a `tab`, `window`, or `<iframe>`) Details: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target | `"_blank" \| "_parent" \| "_self" \| "_top"` | `undefined` |
| `type` | `type` | The default behavior of the button | `"button" \| "reset" \| "submit"` | `'button'` |
| `variant` | `variant` | The variant of button to apply on top of the appearance | `"danger" \| "ghost" \| "standard"` | `'standard'` |
| `variant` | `variant` | The variant of button to apply on top of the appearance (applicable only to `appearance="primary"`) | `"danger" \| "ghost" \| "standard"` | `'standard'` |


## Events
Expand Down
143 changes: 65 additions & 78 deletions packages/bee-q/src/components/button/scss/bq-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,82 @@
@import './bq-button.variables';

@layer components {
.button-disabled {
@apply disabled:border-ui-secondary-disabled disabled:bg-ui-secondary-disabled disabled:text-text-secondary;
@apply disabled:hover:border-ui-secondary-disabled disabled:hover:bg-ui-secondary-disabled disabled:hover:text-text-secondary;
}

.button--text-link__disabled {
@apply disabled:border-transparent disabled:bg-transparent disabled:text-text-secondary;
@apply disabled:hover:border-transparent disabled:hover:bg-transparent disabled:hover:text-text-secondary;
}

/* SVG spinner icon animation */
@keyframes rotate {
100% {
transform: rotate(360deg);
}
}

@keyframes loading--spin {
0% {
transform: rotate(0deg);
}

to {
transform: rotate(1turn);
}
// Common button base style
.bq-button {
@apply box-border flex cursor-[inherit] items-center justify-center rounded-m border-2 border-solid border-transparent text-m font-medium leading-large;
@apply transition-[background-color,border-color,color] duration-300;
@apply disabled:cursor-not-allowed;
@apply focus-visible:focus;
}
}

:host {
@apply relative inline-block w-auto cursor-pointer;
}

.bq-button {
@apply box-border flex cursor-[inherit] items-center justify-center rounded-m border-2 border-solid border-transparent text-m font-medium leading-large;
@apply transition-[background-color,border-color,box-shadow] duration-200;
@apply focus:outline-none focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-system-alert;
@apply active:outline-none disabled:cursor-not-allowed;
}

// Appearance
/* -------------------------------------------------------------------------- */
/* Appearance */
/* -------------------------------------------------------------------------- */

.bq-button--primary {
@apply bg-ui-primary text-text-inverse hover:bg-ui-primary-hover active:bg-ui-primary-active;

&.ghost {
@apply border-ui-primary bg-transparent text-ui-primary hover:text-text-inverse;
@apply hover:border-ui-primary-hover hover:bg-ui-primary-hover;
@apply active:border-ui-primary-active active:bg-ui-primary-active;
}

&.danger {
@apply border-system-danger bg-system-danger;
@apply hover:border-system-danger-hover hover:bg-system-danger-hover;
@apply active:border-system-danger-active active:bg-system-danger-active;

&.disabled {
@apply button-disabled;
}
}

&.disabled {
@apply disabled:border-ui-primary-disabled disabled:bg-ui-primary-disabled disabled:text-text-accent;
@apply disabled:hover:border-ui-primary-disabled disabled:hover:bg-ui-primary-disabled disabled:hover:text-text-accent;
}
@apply bg-ui-brand text-text-inverse;
// Primary `HOVER` and `ACTIVE` state
@apply hover:bg-ui-brand-hover active:bg-ui-brand-active;
// Primary `DISABLED` state
@apply disabled:border-stroke-brand-disabled disabled:bg-ui-brand-disabled;
@apply disabled:hover:border-stroke-brand-disabled disabled:hover:bg-ui-brand-disabled;
}

.bq-button--primary.ghost {
@apply border-stroke-brand bg-transparent text-text-brand;
// Primary ghost `HOVER` state
@apply hover:border-stroke-brand-hover hover:text-text-brand-hover;
// Primary ghost `ACTIVE` state
@apply active:border-stroke-brand-active active:text-text-brand-active;
// Primary ghost `DISABLED` state
@apply disabled:border-stroke-brand-disabled disabled:bg-transparent disabled:text-text-brand-disabled;
@apply disabled:hover:border-stroke-brand-disabled disabled:hover:bg-transparent disabled:hover:text-text-brand-disabled;
}

.bq-button--primary.danger {
@apply bg-ui-danger text-text-inverse;
// Primary danger `HOVER` and `ACTIVE` state
@apply hover:bg-ui-danger-hover active:bg-ui-danger-active;
// Primary danger `DISABLED` state
@apply disabled:border-stroke-danger-disabled disabled:bg-ui-danger-disabled;
@apply disabled:hover:border-stroke-danger-disabled disabled:hover:bg-ui-danger-disabled;
}

.bq-button--secondary {
@apply bg-ui-secondary text-text-primary hover:bg-ui-secondary-hover active:bg-ui-secondary-active;

&.ghost {
@apply border-ui-inverse bg-transparent text-text-primary;
@apply hover:border-ui-secondary-hover hover:bg-ui-secondary-hover;
@apply active:border-ui-secondary-active active:bg-ui-secondary-active;
}

&.disabled {
@apply button-disabled;
}
@apply bg-ui-secondary text-text-primary;
// Secondary `HOVER` and `ACTIVE` state
@apply hover:bg-ui-secondary-hover active:bg-ui-secondary-active;
// Secondary `DISABLED` state
@apply disabled:border-stroke-secondary-disabled disabled:bg-ui-secondary-disabled disabled:text-text-primary-disabled;
@apply disabled:hover:border-stroke-secondary-disabled disabled:hover:bg-ui-secondary-disabled;
}

.bq-button--link {
@apply bg-transparent text-text-accent no-underline hover:bg-ui-secondary-hover active:bg-ui-secondary-active;
@apply bg-transparent text-text-brand no-underline;
// Link `HOVER` state
@apply hover:bg-ui-secondary-hover hover:text-text-brand-hover;
// Link `ACTIVE` state
@apply active:bg-ui-secondary-active active:text-text-brand-active;

&.disabled {
@apply button--text-link__disabled;
@apply cursor-not-allowed bg-transparent text-text-brand-disabled;
}
}

.bq-button--text {
@apply bg-transparent text-text-primary hover:bg-ui-secondary-hover active:bg-ui-secondary-active;

&.disabled {
@apply button--text-link__disabled;
}
// Text `HOVER` state
@apply disabled:bg-transparent disabled:text-text-primary-disabled;
}

// Size
/* -------------------------------------------------------------------------- */
/* Size */
/* -------------------------------------------------------------------------- */

.small {
@apply h-[var(--bq-button--small-height)] px-[var(--bq-button--small-paddingX)] py-[var(--bq-button--small-paddingY)];
Expand All @@ -115,13 +94,17 @@
@apply h-[var(--bq-button--large-height)] px-[var(--bq-button--large-paddingX)] py-[var(--bq-button--large-paddingY)];
}

// Label
/* -------------------------------------------------------------------------- */
/* Label */
/* -------------------------------------------------------------------------- */

.bq-button__label ::slotted(bq-icon) {
@apply flex;
}

// Prefix and Suffix slots
/* -------------------------------------------------------------------------- */
/* Prefix and Suffix slots */
/* -------------------------------------------------------------------------- */

.bq-button__prefix,
.bq-button__suffix {
Expand All @@ -136,7 +119,9 @@
@apply pr-1;
}

// Loading
/* -------------------------------------------------------------------------- */
/* Loading */
/* -------------------------------------------------------------------------- */

.bq-button.loading {
@apply relative cursor-wait;
Expand All @@ -148,8 +133,10 @@
@apply invisible;
}

// Spinner icon
/* -------------------------------------------------------------------------- */
/* Spinner icon */
/* -------------------------------------------------------------------------- */

.bq-button__loader {
@apply absolute animate-[loading--spin_1s_infinite_linear];
@apply absolute animate-spin;
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ Disabled.args = {

export const Indeterminate = (args) => {
const allCheckboxChange = (event) => {
const interestCheckboxes = [...document.querySelectorAll('bq-checkbox[name="interest"')] as HTMLInputElement[];
const interestCheckboxes = [
...Array.from(document.querySelectorAll<HTMLInputElement>('bq-checkbox[name="interest"')),
];
interestCheckboxes.forEach((interestCheckbox: HTMLInputElement) => {
interestCheckbox.checked = event.detail.checked;
});
};

const interestCheckboxChange = (event) => {
const allInterestCheckbox = document.querySelector('bq-checkbox[name="all-interests"') as HTMLInputElement;
const interestCheckboxChange = () => {
const allInterestCheckbox = document.querySelector<HTMLInputElement>('bq-checkbox[name="all-interests"');
const interestCheckboxes = document.querySelectorAll('bq-checkbox[name="interest"');
const onlyChecked = document.querySelectorAll('bq-checkbox[name="interest"][checked]').length;
allInterestCheckbox.indeterminate = onlyChecked > 0 && onlyChecked < interestCheckboxes.length;
Expand Down
Loading