Skip to content

Commit

Permalink
feat(Tokens): add extended palette color and update declarative colors (
Browse files Browse the repository at this point in the history
  • Loading branch information
dgonzalezr committed Apr 27, 2023
1 parent 26c2929 commit be11954
Show file tree
Hide file tree
Showing 48 changed files with 1,016 additions and 285 deletions.
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

0 comments on commit be11954

Please sign in to comment.