Skip to content

Commit 8c8087d

Browse files
committed
Fix desktop styles not working
1 parent 200a3c2 commit 8c8087d

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# HTML Sheet Element
22

3-
HTML Custom Element for creating sheets. Displayed as a bottom sheet on mobile and centered sheet on desktop.
3+
HTML Custom Element for creating sheets. Displayed as a bottom sheet on mobile and a centered sheet on desktop.
44

55

66
## Features
77

8-
- There is a draggable area to open or close the sheet
9-
- The sheet can be closed using a button in the top right corner, using the `Esc` key, or by clicking outside the bottom sheet
8+
- There is a handle at the top of the sheet that can be used to open or close the sheet
9+
- The sheet can be closed using a button in the sheet header, using the `Esc` key, or by clicking outside the bottom sheet
1010
- This behavior is configurable. You can turn off the `Esc` or the click outside the sheet when you want.
1111
- API is similar to the `<dialog>` element's
1212
- Supports forms inside of it

library/styleSheet.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ styleSheet.replaceSync(`
2828
--_sheet-backdrop-color: var(--sheet-backdrop-color, #88888880);
2929
3030
--_sheet-header-padding: var(--sheet-header-padding, 0 0 0 1rem);
31+
--_sheet-title-margin: var(--sheet-title-margin, 0.5rem 0);
3132
--_sheet-body-padding: var(--sheet-body-padding, 1rem);
3233
3334
--_sheet-handle-width: var(--sheet-handle-width, 3rem);
@@ -55,19 +56,8 @@ styleSheet.replaceSync(`
5556
@media (min-width: 48rem) {
5657
:host {
5758
--_sheet-width: var(--sheet-width, auto);
58-
--_sheet-max-width: 48rem;
59-
--_sheet-max-height: 32rem;
60-
61-
border-radius: var(--_sheet-border-radius);
62-
justify-content: center;
63-
}
64-
65-
.sheet-handle-container {
66-
display: none;
67-
}
68-
69-
.sheet-controls {
70-
grid-template-columns: 1fr auto auto;
59+
--_sheet-max-width: var(--sheet-max-width, 48rem);
60+
--_sheet-max-height: var(--sheet-max-height, 32rem);
7161
}
7262
}
7363
@@ -152,6 +142,10 @@ styleSheet.replaceSync(`
152142
justify-content: flex-start;
153143
}
154144
145+
.sheet-title-area:not(:empty) {
146+
padding: var(--_sheet-title-margin);
147+
}
148+
155149
.sheet-handle-container {
156150
display: flex;
157151
flex-direction: column;
@@ -200,4 +194,23 @@ styleSheet.replaceSync(`
200194
padding: var(--_sheet-body-padding);
201195
box-sizing: border-box;
202196
}
197+
198+
/* tablet */
199+
@media (min-width: 48rem) {
200+
:host {
201+
justify-content: center;
202+
}
203+
204+
.sheet-contents {
205+
border-radius: var(--_sheet-border-radius);
206+
}
207+
208+
.sheet-handle-container {
209+
display: none;
210+
}
211+
212+
.sheet-controls {
213+
grid-template-columns: 1fr auto auto;
214+
}
215+
}
203216
`)

test/index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
<button type="button" id="open-sheet" aria-controls="sheet">Open the Sheet</button>
2525

2626
<ui-sheet id="sheet" style="--sheet-body-padding: 0 1rem 1rem 1rem;">
27-
<h2 slot="title-area" style="padding-block: 0.5rem">Contact</h2>
27+
<h2 slot="title-area">Contact</h2>
2828
<form method="dialog" class="column">
2929
<div class="column">
30-
<label for="email">Email</label>
31-
<input name="email" id="email" type="email" placeholder="Your email" required>
30+
<label for="email">Recepient</label>
31+
<input name="email" id="email" type="email" placeholder="Recepient's email" required>
3232
</div>
3333
<div class="column">
3434
<label for="subject">Subject</label>
@@ -38,7 +38,6 @@ <h2 slot="title-area" style="padding-block: 0.5rem">Contact</h2>
3838
<label for="message">Message</label>
3939
<textarea name="message" placeholder="Your message"></textarea>
4040
</div>
41-
<!-- <div contenteditable="true">Contenteditable block</div> -->
4241
<button type="submit" value="send">Send</button>
4342
</form>
4443
</ui-sheet>

test/main.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,3 @@ form > div {
7979
form label {
8080
font-weight: 500;
8181
}
82-
83-
ui-sheet h2 {
84-
padding-block: 0.5rem;
85-
}

0 commit comments

Comments
 (0)