Skip to content

Commit 2bdc447

Browse files
authored
refactor!: update drawer-toggle to not extend button (#7005)
1 parent 081a241 commit 2bdc447

File tree

6 files changed

+69
-55
lines changed

6 files changed

+69
-55
lines changed

packages/app-layout/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"@vaadin/component-base": "24.4.0-alpha1",
4242
"@vaadin/vaadin-lumo-styles": "24.4.0-alpha1",
4343
"@vaadin/vaadin-material-styles": "24.4.0-alpha1",
44-
"@vaadin/vaadin-themable-mixin": "24.4.0-alpha1"
44+
"@vaadin/vaadin-themable-mixin": "24.4.0-alpha1",
45+
"lit": "^3.0.0"
4546
},
4647
"devDependencies": {
4748
"@esm-bundle/chai": "^4.3.4",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2018 - 2023 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import type { CSSResult } from 'lit';
7+
8+
export const drawerToggle: CSSResult;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2018 - 2023 Vaadin Ltd.
4+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5+
*/
6+
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7+
8+
export const drawerToggle = css`
9+
:host {
10+
display: inline-flex;
11+
align-items: center;
12+
justify-content: center;
13+
cursor: default;
14+
position: relative;
15+
outline: none;
16+
height: 24px;
17+
width: 24px;
18+
padding: 4px;
19+
}
20+
21+
[part='icon'],
22+
[part='icon']::after,
23+
[part='icon']::before {
24+
position: absolute;
25+
top: 8px;
26+
height: 3px;
27+
width: 24px;
28+
background-color: #000;
29+
}
30+
31+
[part='icon']::after,
32+
[part='icon']::before {
33+
content: '';
34+
}
35+
36+
[part='icon']::after {
37+
top: 6px;
38+
}
39+
40+
[part='icon']::before {
41+
top: 12px;
42+
}
43+
`;

packages/app-layout/src/vaadin-drawer-toggle.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Copyright (c) 2018 - 2023 Vaadin Ltd.
44
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
55
*/
6-
import { Button } from '@vaadin/button/src/vaadin-button.js';
6+
import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js';
7+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
79

810
/**
911
* The Drawer Toggle component controls the drawer in App Layout component.
@@ -14,7 +16,7 @@ import { Button } from '@vaadin/button/src/vaadin-button.js';
1416
* </vaadin-app-layout>
1517
* ```
1618
*/
17-
declare class DrawerToggle extends Button {
19+
declare class DrawerToggle extends ButtonMixin(DirMixin(ThemableMixin(HTMLElement))) {
1820
ariaLabel: string;
1921
}
2022

packages/app-layout/src/vaadin-drawer-toggle.js

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,16 @@
33
* Copyright (c) 2018 - 2023 Vaadin Ltd.
44
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
55
*/
6-
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
7-
import { Button } from '@vaadin/button/src/vaadin-button.js';
6+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7+
import { buttonStyles } from '@vaadin/button/src/vaadin-button-base.js';
8+
import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js';
89
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
10+
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
911
import { isEmptyTextNode } from '@vaadin/component-base/src/dom-utils.js';
10-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13+
import { drawerToggle } from './vaadin-drawer-toggle-styles.js';
1114

12-
/**
13-
* Use registerStyles instead of the `<style>` tag to make sure
14-
* that this CSS will override core styles of `vaadin-button`.
15-
*/
16-
registerStyles(
17-
'vaadin-drawer-toggle',
18-
css`
19-
:host {
20-
display: inline-flex;
21-
align-items: center;
22-
justify-content: center;
23-
cursor: default;
24-
position: relative;
25-
outline: none;
26-
height: 24px;
27-
width: 24px;
28-
padding: 4px;
29-
}
30-
31-
[part='icon'],
32-
[part='icon']::after,
33-
[part='icon']::before {
34-
position: absolute;
35-
top: 8px;
36-
height: 3px;
37-
width: 24px;
38-
background-color: #000;
39-
}
40-
41-
[part='icon']::after,
42-
[part='icon']::before {
43-
content: '';
44-
}
45-
46-
[part='icon']::after {
47-
top: 6px;
48-
}
49-
50-
[part='icon']::before {
51-
top: 12px;
52-
}
53-
`,
54-
{ moduleId: 'vaadin-drawer-toggle-styles' },
55-
);
15+
registerStyles('vaadin-drawer-toggle', [buttonStyles, drawerToggle], { moduleId: 'vaadin-drawer-toggle-styles' });
5616

5717
/**
5818
* The Drawer Toggle component controls the drawer in App Layout component.
@@ -64,16 +24,18 @@ registerStyles(
6424
* ```
6525
*
6626
* @customElement
67-
* @extends Button
27+
* @extends HTMLElement
28+
* @mixes ButtonMixin
29+
* @mixes DirMixin
30+
* @mixes ThemableMixin
6831
*/
69-
class DrawerToggle extends Button {
32+
class DrawerToggle extends ButtonMixin(DirMixin(ThemableMixin(PolymerElement))) {
7033
static get template() {
7134
return html`
7235
<slot id="slot">
7336
<div part="icon"></div>
7437
</slot>
7538
<div part="icon" hidden$="[[!_showFallbackIcon]]"></div>
76-
<slot name="tooltip"></slot>
7739
`;
7840
}
7941

packages/app-layout/test/dom/__snapshots__/drawer-toggle.test.snap.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ snapshots["vaadin-app-layout default"] =
1111
part="icon"
1212
>
1313
</div>
14-
<slot name="tooltip">
15-
</slot>
1614
`;
1715
/* end snapshot vaadin-app-layout default */
1816

0 commit comments

Comments
 (0)