Skip to content

Commit 313c187

Browse files
committed
chore(mixins): add a mixin for making resizable containers in examples
1 parent 4930ef6 commit 313c187

File tree

8 files changed

+103
-141
lines changed

8 files changed

+103
-141
lines changed

src/components/action-bar/examples/_application.scss

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1+
@use '../../../style/mixins';
2+
13
.application {
24
position: relative;
3-
45
overflow: hidden;
56
height: 20rem;
6-
77
border: 1px solid rgb(var(--contrast-500));
88
border-radius: 0.5rem;
99
background-color: rgb(var(--contrast-400));
1010

1111
&.is-resizable {
12-
resize: horizontal;
13-
max-width: 100%;
14-
min-width: 10rem;
15-
16-
&::after {
17-
content: 'Resize me ⤵';
18-
font-size: 0.75rem;
19-
position: absolute;
20-
right: 0.25rem;
21-
bottom: 0.25rem;
22-
}
12+
@include mixins.is-resizable(
13+
$direction: horizontal,
14+
$min-width: 10rem,
15+
$min-height: 5rem
16+
);
2317
}
2418

2519
&.has-floating-action-bar {

src/components/ai-avatar/examples/ai-avatar-basic.scss

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
1+
@use '../../../style/mixins';
2+
13
:host {
24
--example-controls-max-columns-width: 100%;
35
}
46

57
.avatar-container {
6-
transition: background-color 0.3s ease;
7-
8-
display: block;
9-
position: relative;
10-
resize: horizontal;
11-
overflow: auto;
12-
13-
box-sizing: border-box;
14-
15-
min-width: 3rem;
16-
max-width: 100%;
8+
@include mixins.is-resizable(
9+
$direction: horizontal,
1710

18-
min-height: 2rem;
19-
height: auto;
20-
max-height: 20rem;
21-
22-
padding: 1rem 0.25rem 3rem 0.25rem;
23-
border: 0.125rem dashed rgb(var(--contrast-500));
24-
25-
border-radius: 0.5rem;
26-
27-
&:after {
28-
content: 'Resize me ⤵';
29-
font-size: 0.75rem;
30-
position: absolute;
31-
right: 0.25rem;
32-
bottom: 0.25rem;
33-
}
11+
$min-width: 3rem,
12+
$height: auto,
13+
$min-height: 2rem
14+
);
15+
transition: background-color 0.3s ease;
3416
}
3517

3618
limel-ai-avatar {

src/components/card/examples/card-resizable-container.scss

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1+
@use '../../../style/mixins';
2+
13
:host {
4+
@include mixins.is-resizable(
5+
$direction: both,
6+
$min-width: 10rem,
7+
$width: 20rem,
8+
$min-height: 5rem,
9+
$height: auto
10+
);
211
display: block;
3-
position: relative;
4-
resize: both;
5-
overflow: auto;
6-
7-
box-sizing: border-box;
8-
9-
min-width: 10rem;
10-
width: 20rem;
11-
max-width: 100%;
12-
13-
min-height: 5rem;
14-
height: auto;
15-
max-height: 50rem;
16-
17-
padding: 1rem 1rem 3rem 1rem;
18-
border: 0.125rem dashed rgb(var(--contrast-500));
19-
20-
border-radius: 0.5rem;
21-
22-
&::after {
23-
content: 'Resize me ⤵';
24-
font-size: 0.75rem;
25-
position: absolute;
26-
right: 0.25rem;
27-
bottom: 0.25rem;
28-
}
2912
}
3013

3114
:host(limel-example-card-orientation),

src/components/chart/examples/chart-resizable-container.scss

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
1+
@use '../../../style/mixins';
2+
13
* {
24
box-sizing: border-box;
35
}
46

57
:host {
6-
position: relative;
78
display: flex;
89
flex-direction: column;
910
gap: 1rem;
1011

11-
resize: both;
12-
overflow: auto;
13-
14-
box-sizing: border-box;
15-
16-
min-width: 10rem;
17-
width: 100%;
18-
max-width: 100%;
19-
20-
min-height: 5rem;
21-
height: 100%;
22-
max-height: 50rem;
23-
24-
padding: 1rem 1rem 3rem 1rem;
25-
border: 0.125rem dashed rgb(var(--contrast-500));
26-
27-
border-radius: 0.5rem;
28-
29-
&::after {
30-
content: 'Resize me ⤵';
31-
font-size: 0.75rem;
32-
position: absolute;
33-
right: 0.25rem;
34-
bottom: 0.25rem;
35-
}
12+
@include mixins.is-resizable(
13+
$direction: both,
14+
$min-width: 10rem,
15+
$min-height: 5rem
16+
);
3617
}
3718

3819
:host(.large) {
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
div {
2-
resize: both;
3-
overflow: auto;
4-
5-
box-sizing: border-box;
6-
position: relative;
7-
8-
min-width: 8rem;
9-
width: 12rem;
10-
max-width: 40rem;
1+
@use '../../../style/mixins';
112

12-
min-height: 8rem;
13-
height: 12rem;
14-
max-height: 40rem;
15-
16-
padding: 1rem;
17-
border: 0.125rem dashed rgb(var(--contrast-500));
3+
div {
4+
@include mixins.is-resizable(
5+
$direction: both,
6+
$width: 12rem,
7+
$min-width: 8rem,
8+
$max-width: 40rem,
9+
$height: 12rem,
10+
$min-height: 8rem,
11+
$max-height: 40rem
12+
);
1813
}

src/components/menu/examples/menu-surface-width.scss

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use '../../../style/mixins';
2+
13
:host(limel-example-menu-surface-width) {
24
box-sizing: border-box;
35
display: flex;
@@ -6,21 +8,12 @@
68
}
79

810
.is-resizable {
9-
position: relative;
10-
resize: horizontal;
11-
overflow: auto;
12-
width: clamp(10rem, 30rem, 100%);
13-
14-
padding: 0.5rem 0.5rem 3rem 0.5rem;
15-
border: 1px solid rgb(var(--contrast-500));
16-
17-
&::after {
18-
content: 'Resize me ⤵';
19-
font-size: 0.75rem;
20-
position: absolute;
21-
right: 0.25rem;
22-
bottom: 0.25rem;
23-
}
11+
@include mixins.is-resizable(
12+
$direction: horizontal,
13+
$min-width: 10rem,
14+
$width: clamp(10rem, 30rem, 100%),
15+
$min-height: 5rem
16+
);
2417
}
2518

2619
limel-menu {

src/components/text-editor/examples/text-editor-size.scss

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1+
@use '../../../style/mixins';
2+
13
:host(limel-example-text-editor-size) {
2-
box-sizing: border-box;
3-
position: relative;
4+
@include mixins.is-resizable(
5+
$direction: both,
6+
$min-width: 10rem,
7+
$min-height: 5rem
8+
);
49
display: block;
5-
6-
overflow: auto;
7-
resize: both;
8-
max-width: 100%;
9-
10-
border: 1px dashed rgb(var(--contrast-700));
11-
padding: 0.75rem;
12-
padding-bottom: 2rem;
13-
14-
&::after {
15-
content: 'Resize me ⤵';
16-
font-size: 0.75rem;
17-
position: absolute;
18-
right: 0.25rem;
19-
bottom: 0.25rem;
20-
}
2110
}
2211

2312
limel-text-editor {

src/style/mixins.scss

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,51 @@ $clickable-normal-state-transitions: (
460460
background-size: 0.5rem;
461461
}
462462

463+
/**
464+
* Make a container resizable by the user.
465+
* This is used in the documentations and examples
466+
* of some components, to demonstrate how the component
467+
* behaves in a resizable container.
468+
*/
469+
@mixin is-resizable(
470+
$direction: both,
471+
// can be `horizontal`, `vertical`, or `both`
472+
$width: 100%,
473+
$min-width: 10rem,
474+
$max-width: 100%,
475+
$height: 100%,
476+
$min-height: 5rem,
477+
$max-height: 50rem
478+
) {
479+
box-sizing: border-box;
480+
position: relative;
481+
482+
border: 1px dashed rgb(var(--contrast-700));
483+
padding: 0.75rem;
484+
padding-bottom: 2rem;
485+
486+
resize: $direction;
487+
overflow: auto;
488+
489+
min-width: $min-width;
490+
width: $width;
491+
max-width: $max-width;
492+
493+
min-height: $min-height;
494+
height: $height;
495+
max-height: $max-height;
496+
497+
border-radius: 0.5rem;
498+
499+
&::after {
500+
content: 'Resize me ⤵';
501+
font-size: 0.75rem;
502+
position: absolute;
503+
right: 0.25rem;
504+
bottom: 0.25rem;
505+
}
506+
}
507+
463508
// Hide element visually while keeping it accessible to assistive technologies
464509
// See: https://www.a11yproject.com/posts/2013-01-11-how-to-hide-content/
465510
// See: https://hugogiraudel.com/2016/10/13/css-hide-and-seek/

0 commit comments

Comments
 (0)