Skip to content

Commit 7388f7e

Browse files
committed
feat(demo): use shoelace instead of material for dynamic examples
1 parent 348f506 commit 7388f7e

File tree

4 files changed

+40
-26
lines changed

4 files changed

+40
-26
lines changed

projects/elements-demo/src/app/features/examples/dynamic/dynamic.component.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,37 @@ <h2 id="dynamic-element-tag">Dynamic element tag</h2>
3636
<ng-template #loading>Loading...</ng-template>
3737
<ax-lazy-element
3838
*axLazyElementDynamic="
39-
'mwc-button';
40-
url: 'https://unpkg.com/&#64;material/mwc-button&#64;0.27.0/mwc-button.js?module';
39+
'sl-button';
40+
url: 'https://cdn.jsdelivr.net/npm/&#64;shoelace-style/shoelace&#64;2.3.0/dist/components/button/button.js';
4141
loadingTemplate: loading;
4242
module: true
4343
"
44-
[outlined]="buttonTypeIsOutlined"
45-
[raised]="!buttonTypeIsOutlined"
44+
[variant]="isButtonVariantPrimary ? 'primary' : 'default'"
4645
(click)="increment1()"
4746
>
4847
Increment
4948
</ax-lazy-element>
5049
<p>Counter: {{ counter1 }}</p>
5150
<div class="controls">
52-
<span>Raised button</span>
51+
<span>Default button</span>
5352
<mat-slide-toggle
54-
[(ngModel)]="buttonTypeIsOutlined"
53+
[(ngModel)]="isButtonVariantPrimary"
5554
></mat-slide-toggle>
56-
<span>Outline button</span>
55+
<span>Primary button</span>
5756
</div>
5857
</ng-template>
5958
</demo-example>
6059
<div class="description">
6160
<p>
6261
In this example we're loading
63-
<code>&#60;mwc-button></code>
62+
<code>&#60;sl-button></code>
6463
using the
6564
<code>*axLazyElementDynamic</code>
6665
directive. Please notice that the original HTML element used in the
6766
template is
6867
<code>&#60;ax-lazy-element></code>
6968
and we're specifying the desired tag as the first parameter of
70-
<code>*axLazyElementDynamic='mwc-button'</code>
69+
<code>*axLazyElementDynamic='sl-button'</code>
7170
. Please, feel free to open your browsers dev tools to check resulting
7271
element tag!
7372
</p>
@@ -142,9 +141,11 @@ <h2 id="multiple-different-dynamic-elements">
142141
loadingTemplate: loading
143142
"
144143
(click)="performAction(c.actionName)"
145-
raised
144+
[name]="c.name ? c.name : undefined"
146145
>
147-
{{ c.content }}
146+
@if (c.content) {
147+
{{ c.content }}
148+
}
148149
</ax-lazy-element>
149150
}
150151
</div>

projects/elements-demo/src/app/features/examples/dynamic/dynamic.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
flex: 1.5;
4343
}
4444

45+
.actions {
46+
display: flex;
47+
gap: 20px;
48+
align-items: center;
49+
}
50+
4551
.controls {
4652
display: flex;
4753
align-items: center;

projects/elements-demo/src/app/features/examples/dynamic/dynamic.component.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export class DynamicComponent implements OnInit {
3737
codeExample3html = CODE_EXAMPLE_3_HTML;
3838

3939
// example state
40-
buttonTypeIsOutlined = true;
40+
isButtonVariantPrimary = true;
4141
counter1 = 0;
4242
counter2 = 0;
4343
counter3 = 0;
4444

4545
dynamicConfigs = [
4646
{
47-
tag: 'mwc-button',
48-
url: 'https://unpkg.com/@material/[email protected].0/mwc-button.js?module',
47+
tag: 'sl-button',
48+
url: 'https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected].0/dist/components/button/button.js',
4949
isModule: true,
5050
content: 'Increment',
5151
actionName: 'increment',
@@ -57,9 +57,10 @@ export class DynamicComponent implements OnInit {
5757
actionName: 'decrement',
5858
},
5959
{
60-
tag: 'mwc-icon',
61-
url: 'https://unpkg.com/@material/[email protected]/mwc-icon.js?module',
62-
content: 'replay',
60+
tag: 'sl-icon',
61+
url: 'https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/dist/components/icon/icon.js',
62+
isModule: true,
63+
name: 'reset',
6364
actionName: 'reset',
6465
},
6566
];
@@ -89,15 +90,15 @@ export class DynamicComponent implements OnInit {
8990
}
9091
}
9192

92-
export const CODE_EXAMPLE_1 = `<!-- url = 'https://unpkg.com/@material/[email protected].0/mwc-button.js?module' -->;
93-
<ax-lazy-element *axLazyElementDynamic="'mwc-button', url: url; module: true"
94-
[outlined]="true"
93+
export const CODE_EXAMPLE_1 = `<!-- url = 'https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected].0/dist/components/button/button.js' -->;
94+
<ax-lazy-element *axLazyElementDynamic="'sl-button', url: url; module: true"
95+
variant="primary"
9596
(click)="increment()">
9697
Increment
9798
</ax-lazy-element>
9899
99100
<!-- will be rendered as ...
100-
<mwc-button outlined (click)="increment()">Increment</mwc-button>
101+
<sl-button variant="primary" (click)="increment()">Increment</sl-button>
101102
-->`;
102103

103104
export const CODE_EXAMPLE_2_HTML = `<ax-lazy-element *axLazyElementDynamic="'wired-button'" (click)="increment()">
@@ -156,8 +157,8 @@ export const CODE_EXAMPLE_3_HTML = `&#64;for(c of dynamicConfigs; track c.url) {
156157
<!--
157158
dynamicConfigs = [
158159
{
159-
tag: 'mwc-button',
160-
url: 'https://unpkg.com/@material/[email protected].0/mwc-button.js?module',
160+
tag: 'sl-button',
161+
url: 'https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected].0/dist/components/button/button.js',
161162
isModule: true,
162163
content: 'Increment',
163164
actionName: 'increment'
@@ -169,9 +170,9 @@ dynamicConfigs = [
169170
actionName: 'decrement'
170171
},
171172
{
172-
tag: 'mwc-icon',
173-
url: 'https://unpkg.com/@material/[email protected].0/mwc-icon.js?module',
174-
content: 'replay',
173+
tag: 'sl-icon',
174+
url: 'https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected].0/dist/components/icon/icon.js',
175+
name: 'reset',
175176
actionName: 'reset'
176177
}
177178
];
Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)