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

refactor(link): split variants #2431

Merged
merged 39 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3985ccb
refactor(link): split variants
TomMenga Feb 20, 2024
f8adc52
refactor(link): split variants side effects
TomMenga Feb 20, 2024
3d1cb09
chore(link): generate docs
TomMenga Feb 20, 2024
c6b8320
refactor(link-variant): migrate link usages
TomMenga Feb 20, 2024
10041d1
refactor(link): fix inline color
TomMenga Feb 21, 2024
2c59255
refactor(link): update docs
TomMenga Feb 21, 2024
547d5db
refactor(link): fix notification stories
TomMenga Feb 21, 2024
730319e
refactor(link): minor css improvement
TomMenga Feb 21, 2024
3e8874b
refactor(link): minor css improvement pt.2
TomMenga Feb 21, 2024
2f3b899
refactor(link): minor css improvement pt.3
TomMenga Feb 21, 2024
81fa2eb
refactor(link): spec tests
TomMenga Feb 21, 2024
f2a7f4b
refactor(link): fix link imports
TomMenga Feb 21, 2024
d117628
chore: update snaps
TomMenga Feb 23, 2024
2a94261
refactor(link): implement stories
TomMenga Feb 26, 2024
81c398a
refactor(link): implement stories
TomMenga Feb 26, 2024
1a8d524
refactor(popover): use inline links in stories
TomMenga Feb 27, 2024
e776ba9
refactor(link): pr feedbacks
TomMenga Feb 27, 2024
d937a81
refactor(link): pr feedbacks
TomMenga Feb 27, 2024
c1a5661
refactor(link): update readmes
TomMenga Feb 27, 2024
8f1a72b
refactor(link): update stories
TomMenga Feb 27, 2024
96cf389
refactor(link): css feedbacks
TomMenga Feb 27, 2024
2ee8773
refactor: migrate mixins
jeripeierSBB Feb 28, 2024
9da7532
refactor: migrate mixins
jeripeierSBB Feb 28, 2024
c870737
docs: use english term in block-link-button docs
jeripeierSBB Feb 28, 2024
e6ad5e9
fix: remove disabled from ButtonProperties and LinkProperties
jeripeierSBB Feb 28, 2024
e6979fb
refactor(link): minor feedbacks
TomMenga Feb 28, 2024
43ffbf2
chore(wtr): increase timeout to 6sec
TomMenga Feb 28, 2024
604b5e3
feat(teaser-paid): add delay for chromatic
TomMenga Feb 28, 2024
f039c15
refactor: move logic between action base and link / button
jeripeierSBB Feb 28, 2024
3ec79df
fix: integrity
jeripeierSBB Feb 28, 2024
a232790
docs(action-base): moved comment
TomMenga Feb 28, 2024
e3b0cf7
fix: review
jeripeierSBB Feb 28, 2024
d500ef7
docs(action-base): moved comment
TomMenga Feb 28, 2024
71edb0e
chore: post merge fixes
TomMenga Feb 28, 2024
080881e
chore: format
TomMenga Feb 28, 2024
29df0eb
refactor: pr feedbacks
TomMenga Feb 29, 2024
df97d93
refactor: pr feedbacks
TomMenga Feb 29, 2024
9fcdde0
refactor: pr feedbacks
TomMenga Feb 29, 2024
cc5dac9
chore: integrity
TomMenga Feb 29, 2024
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
2 changes: 1 addition & 1 deletion src/components/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@forward 'core/styles' hide development-style, host-component-properties, link-base,
link-focus-visible, link-hover, link-active, link-inline-base, link-inline-consolidation;
link-focus-visible, link-hover, link-active, link-consolidation;
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ snapshots["sbb-action-group renders renders - Dom"] =
>
Button
</sbb-button>
<sbb-link
<sbb-block-link
data-slot-names="unnamed"
dir="ltr"
href="https://github.com/lyne-design-system/lyne-components"
icon-name="chevron-small-left-small"
icon-placement="start"
role="link"
size="m"
tabindex="0"
variant="block"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
`;
/* end snapshot sbb-action-group renders renders - Dom */
Expand Down
18 changes: 5 additions & 13 deletions src/components/action-group/action-group.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { html } from 'lit/static-html.js';

import type { SbbButtonElement } from '../button';
import { waitForLitRender } from '../core/testing';
import type { SbbLinkElement } from '../link';
import type { SbbBlockLinkElement } from '../link';

import { SbbActionGroupElement } from './action-group';

Expand All @@ -14,13 +14,13 @@ describe('sbb-action-group', () => {
element = await fixture(html`
<sbb-action-group align-group="start" orientation="horizontal">
<sbb-button variant="secondary">Button</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
icon-placement="start"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
`);
});
Expand Down Expand Up @@ -50,17 +50,9 @@ describe('sbb-action-group', () => {
element.setAttribute('link-size', 's');
await waitForLitRender(element);
const links = Array.from(
document.querySelectorAll('sbb-action-group sbb-link'),
) as SbbLinkElement[];
document.querySelectorAll('sbb-action-group sbb-block-link'),
) as SbbBlockLinkElement[];
expect(links.every((l) => l.size === 's')).to.be.ok;
});

it('should apply variant block to sbb-link', async () => {
await waitForLitRender(element);
const links = Array.from(
document.querySelectorAll('sbb-action-group sbb-link'),
) as SbbLinkElement[];
expect(links.every((l) => l.variant === 'block')).to.be.ok;
});
});
});
2 changes: 1 addition & 1 deletion src/components/action-group/action-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ $horizontal-orientations: (
}
}

::slotted(:is(sbb-link, sbb-link-button)) {
::slotted(:is(sbb-block-link, sbb-block-link-button, sbb-block-link-static)) {
TomMenga marked this conversation as resolved.
Show resolved Hide resolved
white-space: nowrap;
}
37 changes: 11 additions & 26 deletions src/components/action-group/action-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { testA11yTreeSnapshot } from '../core/testing/a11y-tree-snapshot';
import type { SbbActionGroupElement } from './action-group';
import './action-group';
import '../button';
import '../link';
import '../link/block-link';

describe('sbb-action-group', () => {
describe('renders', () => {
Expand All @@ -18,12 +18,12 @@ describe('sbb-action-group', () => {
element = await fixture(html`
<sbb-action-group align-group="start" orientation="horizontal">
<sbb-button variant="secondary">Button</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
`);
await waitForLitRender(element);
Expand All @@ -50,12 +50,12 @@ describe('sbb-action-group', () => {
const root = (await fixture(html`
<sbb-action-group align-group="start" orientation="horizontal">
<sbb-button variant="secondary">Button</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
`)) as SbbActionGroupElement;
expect(assertButtons(root, (b) => b.size === 'l')).to.be.ok;
Expand All @@ -65,46 +65,31 @@ describe('sbb-action-group', () => {
const root = (await fixture(html`
<sbb-action-group align-group="start" orientation="horizontal" button-size="m">
<sbb-button variant="secondary">Button</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
`)) as SbbActionGroupElement;
expect(assertButtons(root, (b) => b.size === 'm')).to.be.ok;
});

it('should apply block variant to sbb-link', async () => {
const root = (await fixture(html`
<sbb-action-group align-group="start" orientation="horizontal" button-size="m">
<sbb-button variant="secondary">Button</sbb-button>
<sbb-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-action-group>
`)) as SbbActionGroupElement;
expect(Array.from(root.querySelectorAll('sbb-link')).every((l) => l.variant === 'block')).to
.be.ok;
});

it('should sync link-size property with sbb-link', async () => {
const root = (await fixture(html`
<sbb-action-group align-group="start" orientation="horizontal" link-size="s">
<sbb-button variant="secondary">Button</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
`)) as SbbActionGroupElement;
expect(Array.from(root.querySelectorAll('sbb-link')).every((l) => l.size === 's')).to.be.ok;
expect(Array.from(root.querySelectorAll('sbb-block-link')).every((l) => l.size === 's')).to.be
.ok;
});
});
});
6 changes: 3 additions & 3 deletions src/components/action-group/action-group.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { sbbSpread } from '../core/dom';

import readme from './readme.md?raw';
import './action-group';
import '../link';
import '../link/block-link';
import '../button';

const secondaryButtonTemplate = (alignSelf?: string): TemplateResult => html`
Expand All @@ -21,13 +21,13 @@ const buttonTemplate = (alignSelf?: string): TemplateResult => html`
`;

const linkTemplate = (alignSelf?: string): TemplateResult => html`
<sbb-link
<sbb-block-link
align-self=${alignSelf || nothing}
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
`;

const TemplateTwoElements = (
Expand Down
22 changes: 13 additions & 9 deletions src/components/action-group/action-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import { customElement, property } from 'lit/decorators.js';

import type { SbbButtonElement, SbbButtonLinkElement, SbbButtonSize } from '../button';
import type { SbbHorizontalFrom, SbbOrientation } from '../core/interfaces';
import type { SbbLinkButtonElement, SbbLinkElement, SbbLinkSize } from '../link';
import type {
SbbBlockLinkButtonElement,
SbbBlockLinkElement,
SbbBlockLinkStaticElement,
SbbLinkSize,
} from '../link';

import style from './action-group.scss?lit&inline';

/**
* It can be used as a container for one or more action element, like `sbb-button` or `sbb-link`.
* It can be used as a container for one or more action element, like `sbb-button` or `sbb-block-link`.
*
* @slot - Use the unnamed slot to add `sbb-link` or `sbb-button` elements to the `sbb-action-group`.
* @slot - Use the unnamed slot to add `sbb-block-link` or `sbb-button` elements to the `sbb-action-group`.
*/
@customElement('sbb-action-group')
export class SbbActionGroupElement extends LitElement {
Expand Down Expand Up @@ -43,8 +48,8 @@ export class SbbActionGroupElement extends LitElement {
public buttonSize: SbbButtonSize = 'l';

/**
* Size of the nested sbb-link instances. This will overwrite the size attribute of nested
* sbb-link instances.
* Size of the nested sbb-block-link instances. This will overwrite the size attribute of nested
* sbb-block-link instances.
*/
@property({ attribute: 'link-size', reflect: true })
public linkSize: SbbLinkSize = 'm';
Expand All @@ -65,10 +70,9 @@ export class SbbActionGroupElement extends LitElement {
}

private _syncLinks(): void {
this.querySelectorAll?.<SbbLinkElement | SbbLinkButtonElement>(
'sbb-link, sbb-link-button',
).forEach((link: SbbLinkElement | SbbLinkButtonElement) => {
link.variant = 'block';
this.querySelectorAll?.<
SbbBlockLinkElement | SbbBlockLinkButtonElement | SbbBlockLinkStaticElement
>('sbb-block-link, sbb-block-link-button, sbb-block-link-static').forEach((link) => {
link.size = this.linkSize;
});
}
Expand Down
42 changes: 21 additions & 21 deletions src/components/action-group/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The `sbb-action-group` component is a generic content container which can contain up to three action items
([sbb-button](/docs/components-sbb-button--docs) or [sbb-link](/docs/components-sbb-link--docs) or other HTML elements)
([sbb-button](/docs/components-sbb-button--docs) or [sbb-block-link](/docs/components-sbb-link-sbb-block-link--docs) or other HTML elements)
in various [allocations](#allocations).

## Style
Expand All @@ -16,30 +16,30 @@ indicate the minimum breakpoint from which the orientation changes to `horizonta
<sbb-action-group orientation="vertical" horizontal-from="small">
<sbb-button variant="secondary">Action 1</sbb-button>
<sbb-button>Action 2</sbb-button>
<sbb-link
<sbb-block-link
align-self="end"
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Action 3
</sbb-link>
</sbb-block-link>
</sbb-action-group>
```

### Button-size and link-size

The two props `button-size` and `link-size` can be used to override, respectively, the size of the inner `sbb-button` and `sbb-link`.
Default values are `l` for `sbb-button` and `m` for `sbb-link`.
The two props `button-size` and `link-size` can be used to override, respectively, the size of the inner `sbb-button` and `sbb-block-link`.
Default values are `l` for `sbb-button` and `m` for `sbb-block-link`.

```html
<sbb-action-group button-size="m" link-size="s">
<sbb-button variant="secondary">Action 1</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Action 3
</sbb-link>
</sbb-block-link>
</sbb-action-group>
```

Expand All @@ -51,8 +51,8 @@ possible values are `start`, `center`, `stretch` and `end`.
It is also possible to set the `align-self` attribute on action items in order to move them in the
opposite direction to the group; possible values are `start`, `center` or `end`.

**NOTE**: The `sbb-action-group` will automatically set variant `block` and will sync the `linkSize`
property with nested `sbb-link` and the `buttonSize` property with the nested `sbb-button`
**NOTE**: The `sbb-action-group` will only accept `block-link` and will sync the `linkSize`
TomMenga marked this conversation as resolved.
Show resolved Hide resolved
property with nested `sbb-block-link` and the `buttonSize` property with the nested `sbb-button`
instances.

```html
Expand All @@ -74,12 +74,12 @@ and we consider a template like the following one (possibly removing the link fo
<sbb-action-group>
<sbb-button>Button 1</sbb-button>
<sbb-button>Button 2</sbb-button>
<sbb-link
<sbb-block-link
icon-name="chevron-small-left-small"
href="https://github.com/lyne-design-system/lyne-components"
>
Link
</sbb-link>
</sbb-block-link>
</sbb-action-group>
```

Expand Down Expand Up @@ -120,16 +120,16 @@ The values for `align-group` and `align-self` for the various allocations are as

## Properties

| Name | Attribute | Privacy | Type | Default | Description |
| ---------------- | ----------------- | ------- | ------------------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------- |
| `alignGroup` | `align-group` | public | `'start' \| 'center' \| 'stretch' \| 'end'` | `'start'` | Set the slotted `<sbb-action-group>` children's alignment. |
| `horizontalFrom` | `horizontal-from` | public | `SbbHorizontalFrom` | `'medium'` | Overrides the behaviour of `orientation` property. |
| `orientation` | `orientation` | public | `SbbOrientation` | `'horizontal'` | Indicates the orientation of the components inside the `<sbb-action-group>`. |
| `buttonSize` | `button-size` | public | `SbbButtonSize` | `'l'` | Size of the nested sbb-button instances. This will overwrite the size attribute of nested sbb-button instances. |
| `linkSize` | `link-size` | public | `SbbLinkSize` | `'m'` | Size of the nested sbb-link instances. This will overwrite the size attribute of nested sbb-link instances. |
| Name | Attribute | Privacy | Type | Default | Description |
| ---------------- | ----------------- | ------- | ------------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `alignGroup` | `align-group` | public | `'start' \| 'center' \| 'stretch' \| 'end'` | `'start'` | Set the slotted `<sbb-action-group>` children's alignment. |
| `horizontalFrom` | `horizontal-from` | public | `SbbHorizontalFrom` | `'medium'` | Overrides the behaviour of `orientation` property. |
| `orientation` | `orientation` | public | `SbbOrientation` | `'horizontal'` | Indicates the orientation of the components inside the `<sbb-action-group>`. |
| `buttonSize` | `button-size` | public | `SbbButtonSize` | `'l'` | Size of the nested sbb-button instances. This will overwrite the size attribute of nested sbb-button instances. |
| `linkSize` | `link-size` | public | `SbbLinkSize` | `'m'` | Size of the nested sbb-block-link instances. This will overwrite the size attribute of nested sbb-block-link instances. |

## Slots

| Name | Description |
| ---- | ------------------------------------------------------------------------------------------ |
| | Use the unnamed slot to add `sbb-link` or `sbb-button` elements to the `sbb-action-group`. |
| Name | Description |
| ---- | ------------------------------------------------------------------------------------------------ |
| | Use the unnamed slot to add `sbb-block-link` or `sbb-button` elements to the `sbb-action-group`. |
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ snapshots["sbb-alert should render customized properties"] =
size="s"
tabindex="0"
target="_blank"
variant="inline"
>
Show much more
</sbb-link>
Expand Down
5 changes: 2 additions & 3 deletions src/components/alert/alert/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { customElement, property } from 'lit/decorators.js';

import {
LanguageController,
type LinkProperties,
type LinkTargetType,
SbbIconNameMixin,
} from '../../core/common-behaviors';
Expand Down Expand Up @@ -33,7 +32,7 @@ export type SbbAlertState = 'closed' | 'opening' | 'opened';
* @event {CustomEvent<void>} dismissalRequested - Emits when dismissal of an alert was requested.
*/
@customElement('sbb-alert')
export class SbbAlertElement extends SbbIconNameMixin(LitElement) implements LinkProperties {
export class SbbAlertElement extends SbbIconNameMixin(LitElement) {
public static override styles: CSSResultGroup = style;
public static readonly events = {
willOpen: 'willOpen',
Expand Down Expand Up @@ -154,7 +153,7 @@ export class SbbAlertElement extends SbbIconNameMixin(LitElement) implements Lin
<slot></slot>
</p>
${this.href
? html` <sbb-link ${spread(this._linkProperties())} variant="inline" negative>
? html` <sbb-link ${spread(this._linkProperties())} negative>
${this.linkContent ? this.linkContent : i18nFindOutMore[this._language.current]}
</sbb-link>`
: nothing}
Expand Down
Loading
Loading