Skip to content

Commit d612012

Browse files
committed
chore: set component with children
1 parent a7d1bcf commit d612012

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

example/webpack/App.svelte

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
<script>
22
import 'swiper/swiper.min.css';
33
import Time from './components/Time.svelte';
4+
import Body from './components/Body.svelte';
5+
46
import css from './app.module.css';
57
import { success, successSmall } from './app2.module.css';
68
import './app3.module.css';
79
810
let theme = { color: 'blue'};
911
</script>
10-
<div class="overlay" />
12+
<div class="overlay"></div>
1113
<div class="modal" style="display:block">
1214
<section>
13-
<header class="active" on:click={() => theme.color = 'red'}>My Modal title</header>
14-
<div class="body">
15-
<Time />
15+
<header
16+
class="active"
17+
role="button"
18+
tabindex="-1"
19+
on:click={() => theme.color = 'red'}
20+
on:keyup={() => theme.color = 'green'}
21+
>
22+
My Modal title
23+
</header>
24+
<Body>
25+
<Time class="time" />
1626
<p class="{css.error} {css.errorMessage} large"><strong>Lorem ipsum dolor sit</strong>, amet consectetur adipisicing elit. Placeat, deserunt.</p>
1727
<p class="{success} {successSmall}">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Placeat, deserunt. Lorem ipsum dolor sit amet. </p>
18-
</div>
28+
</Body>
1929
<footer>
2030
<button class="active">Ok</button>
2131
<button class="cancel">Cancel</button>
@@ -61,15 +71,6 @@
6171
color: bind("theme.color");
6272
}
6373
64-
.body {
65-
padding: 1rem;
66-
flex: 1 0 0;
67-
min-height: 0;
68-
max-height: 100%;
69-
overflow: scroll;
70-
-webkit-overflow-scrolling: touch;
71-
}
72-
7374
:local(footer) {
7475
padding: 1rem;
7576
text-align: right;
@@ -90,4 +91,10 @@ button {
9091
.active {
9192
font-weight: 700;
9293
}
94+
95+
@media screen {
96+
.time {
97+
color: red;
98+
}
99+
}
93100
</style>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script>
2+
let { children } = $props();
3+
</script>
4+
5+
<div class="body">
6+
{@render children?.()}
7+
</div>
8+
9+
<style module="mixed">
10+
.body {
11+
padding: 1rem;
12+
flex: 1 0 0;
13+
min-height: 0;
14+
max-height: 100%;
15+
overflow: scroll;
16+
-webkit-overflow-scrolling: touch;
17+
}
18+
</style>

0 commit comments

Comments
 (0)