Skip to content

Commit

Permalink
feat(core/split-button): migrate to shadow DOM (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Jun 29, 2023
1 parent bac0e95 commit 3b6dea9
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 98 deletions.
15 changes: 15 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,18 @@ ___Now___

Remove typo `sencodary` from `variant` property

### `ix-split-button`

Remove deprecated `invisible`-property

___Before___
```tsx
<ix-split-button invisible></ix-split-button>
```

___Now___
```tsx
<ix-split-button ghost></ix-split-button>

```

4 changes: 2 additions & 2 deletions packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1739,14 +1739,14 @@ export declare interface IxSpinner extends Components.IxSpinner {}


@ProxyCmp({
inputs: ['disabled', 'ghost', 'icon', 'invisible', 'label', 'outline', 'placement', 'splitIcon', 'variant']
inputs: ['disabled', 'ghost', 'icon', 'label', 'outline', 'placement', 'splitIcon', 'variant']
})
@Component({
selector: 'ix-split-button',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['disabled', 'ghost', 'icon', 'invisible', 'label', 'outline', 'placement', 'splitIcon', 'variant'],
inputs: ['disabled', 'ghost', 'icon', 'label', 'outline', 'placement', 'splitIcon', 'variant'],
})
export class IxSplitButton {
protected el: HTMLElement;
Expand Down
51 changes: 23 additions & 28 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@
"ix-empty-state",
"ix-menu-about-news",
"ix-modal-example",
"ix-split-button",
"ix-time-picker",
"ix-upload"
],
Expand Down Expand Up @@ -811,6 +812,9 @@
"ix-modal-example": [
"ix-button"
],
"ix-split-button": [
"ix-button"
],
"ix-time-picker": [
"ix-button"
],
Expand Down Expand Up @@ -5010,6 +5014,7 @@
"ix-modal-example",
"ix-pagination",
"ix-select",
"ix-split-button",
"ix-time-picker",
"ix-toast"
],
Expand Down Expand Up @@ -5082,6 +5087,9 @@
"ix-select": [
"ix-icon-button"
],
"ix-split-button": [
"ix-icon-button"
],
"ix-time-picker": [
"ix-icon-button"
],
Expand Down Expand Up @@ -8903,16 +8911,26 @@
"usage": {},
"docs": "",
"docsTags": [],
"encapsulation": "scoped",
"encapsulation": "shadow",
"dependents": [],
"dependencies": [
"ix-icon",
"ix-button",
"ix-icon-button",
"ix-dropdown"
],
"dependencyGraph": {
"ix-split-button": [
"ix-icon",
"ix-button",
"ix-icon-button",
"ix-dropdown"
],
"ix-button": [
"ix-spinner",
"ix-icon"
],
"ix-icon-button": [
"ix-spinner",
"ix-icon"
]
},
"props": [
Expand Down Expand Up @@ -8967,29 +8985,6 @@
"optional": false,
"required": false
},
{
"name": "invisible",
"type": "boolean",
"mutable": false,
"attr": "invisible",
"reflectToAttr": false,
"docs": "Button invisible",
"docsTags": [
{
"name": "deprecated",
"text": "Will be removed in 2.0.0. Use ghost property"
}
],
"default": "false",
"deprecation": "Will be removed in 2.0.0. Use ghost property",
"values": [
{
"type": "boolean"
}
],
"optional": false,
"required": false
},
{
"name": "label",
"type": "string",
Expand Down Expand Up @@ -9103,7 +9098,7 @@
"mutable": false,
"attr": "split-icon",
"reflectToAttr": false,
"docs": "Splitbutton icon",
"docs": "Icon of the button on the right",
"docsTags": [],
"default": "'context-menu'",
"values": [
Expand Down Expand Up @@ -9165,7 +9160,7 @@
"usage": {},
"docs": "",
"docsTags": [],
"encapsulation": "scoped",
"encapsulation": "shadow",
"dependents": [],
"dependencies": [
"ix-dropdown-item"
Expand Down
14 changes: 2 additions & 12 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,11 +1572,6 @@ export namespace Components {
* Button icon
*/
"icon": string;
/**
* Button invisible
* @deprecated Will be removed in 2.0.0. Use ghost property
*/
"invisible": boolean;
/**
* Button label
*/
Expand All @@ -1590,7 +1585,7 @@ export namespace Components {
*/
"placement": Placement;
/**
* Splitbutton icon
* Icon of the button on the right
*/
"splitIcon": string;
/**
Expand Down Expand Up @@ -4463,11 +4458,6 @@ declare namespace LocalJSX {
* Button icon
*/
"icon"?: string;
/**
* Button invisible
* @deprecated Will be removed in 2.0.0. Use ghost property
*/
"invisible"?: boolean;
/**
* Button label
*/
Expand All @@ -4485,7 +4475,7 @@ declare namespace LocalJSX {
*/
"placement"?: Placement;
/**
* Splitbutton icon
* Icon of the button on the right
*/
"splitIcon"?: string;
/**
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

:host {
@include ix-component;

display: inline-block;
width: auto;
height: 2rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
*/

:host {
display: block;
display: contents;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
@Component({
tag: 'ix-split-button-item',
styleUrl: 'split-button-item.css',
scoped: true,
shadow: true,
})
export class SplitButtonItem {
/**
Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/components/split-button/split-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
@import 'mixins/shadow-dom/component';
@import 'components/button-group';

:host {
@include ix-component;
display: inline-block;

.btn-group {
// Overwrite styling from bootstrap button group
position: relative;
display: inline-flex;
vertical-align: middle;
width: 100%;

> button:nth-child(1) {
> ix-button:nth-child(1) {
width: calc(100% - 2rem);
}

> button:nth-child(2) {
> ix-button:nth-child(2) {
width: 2rem;
}
}
Expand Down
74 changes: 27 additions & 47 deletions packages/core/src/components/split-button/split-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Prop,
State,
} from '@stencil/core';
import { getButtonClasses } from '../button/base-button';
import { ButtonVariant } from '../button/button';
import { Placement } from '../dropdown/placement';

Expand All @@ -26,7 +25,7 @@ export type SplitButtonVariant = ButtonVariant;
@Component({
tag: 'ix-split-button',
styleUrl: 'split-button.scss',
scoped: true,
shadow: true,
})
export class SplitButton {
@Element() hostElement!: HTMLIxSplitButtonElement;
Expand All @@ -41,13 +40,6 @@ export class SplitButton {
*/
@Prop() outline = false;

/**
* Button invisible
*
* @deprecated Will be removed in 2.0.0. Use ghost property
*/
@Prop() invisible = false;

/**
* Button invisible
*/
Expand All @@ -64,7 +56,7 @@ export class SplitButton {
@Prop() icon = '';

/**
* Splitbutton icon
* Icon of the button on the right
*/
@Prop() splitIcon = 'context-menu';

Expand Down Expand Up @@ -105,47 +97,35 @@ export class SplitButton {
}

render() {
const buttonAttributes = {
variant: this.variant,
outline: this.outline,
ghost: this.ghost,
disabled: this.disabled,
class: {
'left-button-border': !this.outline,
},
onClick: (e) => this.buttonClick.emit(e),
};
return (
<Host>
<div class={{ 'btn-group': true, 'middle-gap': !this.outline }}>
<button
class={{
...getButtonClasses(
this.variant,
this.outline,
this.ghost || this.invisible,
!this.label,
false,
false,
this.disabled
),
...{
'left-button-border': !this.outline,
},
}}
onClick={(e) => this.buttonClick.emit(e)}
>
{this.icon ? <ix-icon name={this.icon} /> : null} {this.label}
</button>
<button
{this.label ? (
<ix-button {...buttonAttributes} icon={this.icon}>
{this.label}
</ix-button>
) : (
<ix-icon-button
{...buttonAttributes}
icon={this.icon}
></ix-icon-button>
)}
<ix-icon-button
{...buttonAttributes}
ref={(r) => (this.triggerElement = r)}
class={{
...getButtonClasses(
this.variant,
this.outline,
this.ghost || this.invisible,
true,
false,
false,
this.disabled
),
...{
anchor: true,
},
}}
>
<ix-icon name={this.splitIcon} />
</button>
class={'anchor'}
icon={this.splitIcon}
></ix-icon-button>
</div>

<ix-dropdown ref={(r) => (this.dropdownElement = r)}>
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/tests/split-button/split-button.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import { regressionTest } from '@utils/test';
regressionTest.describe('split-button', () => {
regressionTest('basic', async ({ page }) => {
await page.goto('split-button/basic');
await page.locator('.btn-group button:nth-child(2)').click();
await page.waitForSelector('.dropdown-menu.show');

const button = page.locator('ix-split-button');
const dropdownButton = button.getByRole('button', { name: '' });
await expect(dropdownButton).toBeVisible();
await dropdownButton.click();
await expect(button.locator('.dropdown-menu.show')).toBeVisible();
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
maxDiffPixelRatio: 0.02,
});
Expand Down
1 change: 0 additions & 1 deletion packages/vue/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ export const IxSpinner = /*@__PURE__*/ defineContainer<JSX.IxSpinner>('ix-spinne
export const IxSplitButton = /*@__PURE__*/ defineContainer<JSX.IxSplitButton>('ix-split-button', undefined, [
'variant',
'outline',
'invisible',
'ghost',
'label',
'icon',
Expand Down

0 comments on commit 3b6dea9

Please sign in to comment.