uaplus 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # UA+
2
+
3
+ UA+ (User agent plus) is a different type of reset style sheet. Instead of mostly resetting and normalizing properties, we focus on improving existing user agent styles and adding new styles only where browsers fall short.
4
+
5
+ Please note that this project is still in the early alpha phase. Feedback is highly appreciated.
6
+
7
+ ## Who is this for?
8
+
9
+ UAplus is for anyone who wants a better baseline for their style sheets. It does more than other reset style sheets but less than most. Most importantly, we try not to be too opinionated and reset too much. We also take accessibility more into consideration than many others.
10
+
11
+ ## Demo
12
+
13
+ Visit our [demo pages](https://fokus.dev/tools/uaplus/demo/) to compare your browsers' default styles with our improved ones. Please note that the differences are often barely noticeable. That's because we like the default styles and only help out browsers where needed.
package/image.jpg ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "uaplus",
3
+ "version": "0.3.0",
4
+ "description": "User agent styles improvements",
5
+ "keywords": [
6
+ "css"
7
+ ],
8
+ "homepage": "https://github.com/fokus-dev/uaplus#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/fokus-dev/uaplus/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/fokus-dev/uaplus.git"
15
+ },
16
+ "license": "ISC",
17
+ "author": "Manuel Matuzovic",
18
+ "type": "commonjs",
19
+ "main": "index.js"
20
+ }
package/test.html ADDED
@@ -0,0 +1,172 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+
7
+ <title>Tests</title>
8
+
9
+ <link rel="stylesheet" href="uaplus.css">
10
+ </head>
11
+ <body>
12
+ <h1>Tests</h1>
13
+
14
+ <h2>Box Sizing</h2>
15
+
16
+ <div style="width: 100%; border: 10px solid;">A</div>
17
+
18
+ <h2>Focus</h2>
19
+
20
+ <button>A Button</button>
21
+
22
+ <p>Lorem ipsum dolor sit amet <a href="#">consectetur</a> adipisicing elit. Velit deserunt fugit voluptatem quia eveniet voluptatum voluptates quos dolores cum! Consectetur quis cupiditate quidem ea delectus! Tempore magnam dolor pariatur distinctio.</p>
23
+
24
+ <h2>Text</h2>
25
+
26
+ <p>
27
+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Veniam optio reprehenderit magnam voluptatem modi, quisquam tenetur aspernatur harum, neque, repellendus perspiciatis? Voluptates totam praesentium autem ducimus pariatur, eligendi cupiditate quo. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Enim voluptatum excepturi deserunt facere accusamus sunt aliquam? Ducimus doloribus obcaecati veritatis accusantium odio fugit dolor dolores harum optio. Amet, distinctio eum! Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quod ratione quo labore, itaque repudiandae, explicabo quia iure debitis tempore libero cupiditate adipisci accusantium fugiat unde. Quam at asperiores repellendus vero.
28
+ </p>
29
+
30
+ <h2>Headings</h2>
31
+
32
+ <section>
33
+ <h1>Heading</h1>
34
+ <section>
35
+ <h1>Heading</h1>
36
+ <section>
37
+ <h1>Heading</h1>
38
+ </section>
39
+ </section>
40
+ </section>
41
+
42
+ <h2>Abbreviation</h2>
43
+
44
+ <p>
45
+ <abbr title="Hypertext Markup Language">HTML</abbr>
46
+ </p>
47
+
48
+ <h2>Image</h2>
49
+
50
+ <img src="image.jpg" alt="">
51
+
52
+ <h2>iframe</h2>
53
+
54
+ <iframe width="2200" height="650" src="https://www.youtube.com/embed/TA5lHC8kAyk?si=Yo1IVg_ykcOQxw2r" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
55
+
56
+ <h2>fieldset</h2>
57
+
58
+ <fieldset>
59
+ <legend>
60
+ My test
61
+ </legend>
62
+
63
+ <!-- <button style="width: 2000px">Send</button> -->
64
+ </fieldset>
65
+
66
+ <h2>labels</h2>
67
+
68
+ <p>
69
+ <label for="name">name</label>
70
+ <input type="text" id="name">
71
+ </p>
72
+ <p>
73
+ <label for="option">name</label>
74
+ <input type="radio" id="option">
75
+ </p>
76
+ <p>
77
+ <input type="radio" id="option2">
78
+ <label for="option2">name</label>
79
+ </p>
80
+
81
+ <h2>labels</h2>
82
+
83
+ <textarea name="" id=""></textarea>
84
+
85
+ <h2>search</h2>
86
+
87
+ <input type="search">
88
+
89
+ <h2>text in form fields</h2>
90
+
91
+ <button>Heyo</button>
92
+ <input type="text" value="This is a test">
93
+ <select name="" id="">
94
+ <option value="">text</option>
95
+ </select>
96
+
97
+
98
+ <h2>rtl input fields</h2>
99
+
100
+ <p>
101
+ <label for="tel">Tel (ltr)</label>
102
+ <input type="tel" placeholder="86754309" id="tel">
103
+ </p>
104
+ <p>
105
+ <label for="tel2">Tel with value (ltr)</label>
106
+ <input type="tel" value="test" placeholder="86754309" id="tel2">
107
+ </p>
108
+
109
+ <p>
110
+ <label for="tel-rtl">Tel (rtl)</label>
111
+ <input type="tel" dir="rtl" placeholder="86754309" id="tel-rtl">
112
+ </p>
113
+ <p>
114
+ <label for="tel-rtl2">Tel with value (rtl)</label>
115
+ <input type="tel" value="test" dir="rtl" placeholder="86754309" id="tel-rtl2">
116
+ </p>
117
+
118
+
119
+ <h2>tables</h2>
120
+
121
+ <table>
122
+ <tr>
123
+ <th>Q1</th>
124
+ <th>Q2</th>
125
+ <th>Q3</th>
126
+ <th>Q4</th>
127
+ </tr>
128
+ <tr>
129
+ <td>100<br>20</td>
130
+ <td>40</td>
131
+ <td>30</td>
132
+ <td>400</td>
133
+ </tr>
134
+ <tr>
135
+ <td>20</td>
136
+ <td>10</td>
137
+ <td>8</td>
138
+ <td>100</td>
139
+ </tr>
140
+ </table>
141
+
142
+
143
+ <h2>dialogs</h2>
144
+
145
+ <button commandfor="my-modal1" command="show-modal">
146
+ Show modal
147
+ </button>
148
+
149
+ <dialog id="my-modal1" closedby="any">
150
+ <button command="close" commandfor="my-modal1">close</button>
151
+
152
+ <h1>My modal</h1>
153
+ </dialog>
154
+
155
+ <h2>popovers</h2>
156
+
157
+ <button popovertarget="mypopover">Toggle the popover</button>
158
+ <div id="mypopover" popover>Popover content</div>
159
+
160
+ <h2>hidden</h2>
161
+
162
+ <div hidden style="display: block">Hidden</div>
163
+
164
+ <h2>summary</h2>
165
+
166
+ <details>
167
+ <summary>More info</summary>
168
+ <p>This is the hidden info</p>
169
+ </details>
170
+
171
+ </body>
172
+ </html>
package/uaplus.css ADDED
@@ -0,0 +1,309 @@
1
+ /**
2
+ * uaplus.css version 0.3.0
3
+ */
4
+
5
+ /**
6
+ * Wrapping everything in an anonymous layer ensures that selectors
7
+ * in UA+ have the lowest specificty or the highest when using
8
+ * !important.
9
+ */
10
+ @layer {
11
+ /**
12
+ * Different box model
13
+ *
14
+ * We use the traditional box model, where the padding and border
15
+ * of the element is drawn inside and not outside the specified
16
+ * width and height. That makes combining relative and absolute
17
+ * units in properties like <code>inline-size</code> and
18
+ * <code>block-size</code> easier.
19
+ *
20
+ * See https://en.wikipedia.org/wiki/CSS_box_model
21
+ */
22
+ *,
23
+ *::after,
24
+ *::before {
25
+ box-sizing: border-box;
26
+ }
27
+
28
+ /**
29
+ * Improve focus styles
30
+ *
31
+ * Add spacing between content and its focus outline.
32
+ */
33
+ :focus-visible {
34
+ outline-offset: 3px;
35
+ }
36
+
37
+ /**
38
+ * Disable text size adjustment
39
+ *
40
+ * To improve readability on non-mobile optimized websites, browsers
41
+ * like mobile Safari increase the default font size when you switch
42
+ * a website from portrait to landscape. We don't want that for our
43
+ * optimized sites.
44
+ *
45
+ * See https://kilianvalkhof.com/2022/css-html/your-css-reset-needs-text-size-adjust-probably/
46
+ */
47
+ html {
48
+ -webkit-text-size-adjust: none;
49
+ text-size-adjust: none;
50
+ }
51
+
52
+ /**
53
+ * Increase line height
54
+ *
55
+ * Long paragraphs are easier to read if the line height is higher.
56
+ */
57
+ html {
58
+ line-height: 1.5;
59
+ }
60
+
61
+ /**
62
+ * Add scrollbar gutter
63
+ *
64
+ * Prevent the page from “jumping” when switching from a long to a short page.
65
+ *
66
+ */
67
+ html {
68
+ scrollbar-gutter: stable;
69
+ }
70
+
71
+ /**
72
+ * Remove UA styles for h1s nested in sectioning content
73
+ *
74
+ * Nesting h1s in section, articles, etc., shouldn't influence the
75
+ * styling of the heading since nesting doesn't influence
76
+ * semantics either.
77
+ *
78
+ * See https://github.com/whatwg/html/issues/7867#issuecomment-2632395167
79
+ * See https://github.com/whatwg/html/pull/11102
80
+ * See https://html.spec.whatwg.org/#sections-and-headings
81
+ */
82
+ h1 {
83
+ font-size: 2em;
84
+ margin-block: 0.67em;
85
+ }
86
+
87
+ /**
88
+ * Improve abbreviations with titles
89
+ *
90
+ * The abbr element with the title isn't helpful regarding
91
+ * accessibility because support is inconsistent, and it's only
92
+ * accessible to some users. Still, it's commonly used.
93
+ * This rule shows a dotted underline on abbreviations in all
94
+ * browsers (there's a bug in Safari) and changes the cursor.
95
+ *
96
+ * See https://adrianroselli.com/2024/01/using-abbr-element-with-title-attribute.html
97
+ */
98
+ abbr[title] {
99
+ cursor: help;
100
+ text-decoration-line: underline;
101
+ text-decoration-style: dotted;
102
+ }
103
+
104
+ /**
105
+ * Optimize mark element in Forced Colors Mode
106
+ *
107
+ * The colors of the mark element don't change in Forced Colors Mode,
108
+ * which can be problematic. Use system colors instead.
109
+ *
110
+ * See https://adrianroselli.com/2017/12/tweaking-text-level-styles.html#MarkWHCM
111
+ */
112
+ @media (forced-colors: active) {
113
+ mark {
114
+ color: HighlightText;
115
+ background-color: Highlight;
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Avoid overflow caused by embedded content
121
+ *
122
+ * Ensure that embedded content (audio, video, images, etc.)
123
+ * doesn't overflow its container.
124
+ */
125
+ audio,
126
+ iframe,
127
+ img,
128
+ svg,
129
+ video {
130
+ max-block-size: 100%;
131
+ max-inline-size: 100%;
132
+ }
133
+
134
+ /**
135
+ * Prevent fieldsets from causing overflow
136
+ *
137
+ * Reset the default `min-inline-size: min-content` to prevent
138
+ * children from stretching fieldsets
139
+ *
140
+ * See https://github.com/twbs/bootstrap/issues/12359
141
+ * and https://html.spec.whatwg.org/multipage/#the-fieldset-and-legend-elements
142
+ */
143
+ fieldset {
144
+ min-inline-size: 0;
145
+ }
146
+
147
+ /**
148
+ * Turn labels into block elements
149
+ *
150
+ * Labels for inputs, selects, and textarea should be block
151
+ * elements.
152
+ */
153
+ label:has(+ input:not([type="radio"], [type="checkbox"]), select, textarea) {
154
+ display: block;
155
+ }
156
+
157
+ /**
158
+ * Increase the block-size of textareas
159
+ *
160
+ * The default height of textareas is small. We increase it a bit.
161
+ */
162
+ textarea:not([rows]) {
163
+ min-block-size: 6em;
164
+ }
165
+
166
+ /**
167
+ * Inherit font styling in form elements
168
+ *
169
+ * buttons, inputs, selects, and textarea should have the same font
170
+ * family and size as the rest of the page.
171
+ */
172
+ button,
173
+ input,
174
+ select,
175
+ textarea {
176
+ font-family: inherit;
177
+ font-size: inherit;
178
+ }
179
+
180
+ /**
181
+ * Normalize search input styles
182
+ *
183
+ * Remove the rounded corners of search inputs on macOS and IOS
184
+ * and normalize the background color
185
+ */
186
+ [type="search"] {
187
+ -webkit-appearance: textfield;
188
+ }
189
+
190
+ /* iOS only */
191
+ @supports (-webkit-touch-callout: none) {
192
+ [type="search"] {
193
+ border: 1px solid -apple-system-secondary-label;
194
+ background-color: canvas;
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Maintain direction in some input types
200
+ *
201
+ * Some input types should remain left-aligned in right-to-left
202
+ * languages,but only if the value isn't empty because the
203
+ * placeholder should be right-aligned.
204
+ *
205
+ * See https://rtlstyling.com/posts/rtl-styling#form-inputs
206
+ */
207
+ input:where([type="tel"], [type="url"], [type="email"], [type="number"]):not(:placeholder-shown) {
208
+ direction: ltr;
209
+ }
210
+
211
+ /**
212
+ * Improve table styling
213
+ *
214
+ * With the default styling, tables are hard to scan. These rules
215
+ * add padding and collapsed borders.
216
+ */
217
+ table {
218
+ border-collapse: collapse;
219
+ border: 1px solid;
220
+ }
221
+
222
+ th,
223
+ td {
224
+ border: 1px solid;
225
+ padding: 0.25em 0.5em;
226
+ vertical-align: top;
227
+ }
228
+
229
+ /**
230
+ * Fading dialogs
231
+ *
232
+ * Add fade in and fade out transitions for the dialog element
233
+ * and backdrops
234
+ */
235
+ dialog::backdrop {
236
+ background: oklch(0% 0 0 / 0.3);
237
+ }
238
+
239
+ dialog,
240
+ [popover],
241
+ dialog::backdrop {
242
+ opacity: 0;
243
+ transition: opacity 150ms ease-out, display 150ms allow-discrete,
244
+ overlay 150ms allow-discrete;
245
+ }
246
+
247
+ dialog[open],
248
+ :popover-open,
249
+ dialog[open]::backdrop {
250
+ opacity: 1;
251
+ }
252
+
253
+ @starting-style {
254
+ dialog[open],
255
+ :popover-open,
256
+ dialog[open]::backdrop {
257
+ opacity: 0;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Increase specificity of [hidden]
263
+ *
264
+ * Make it harder to accidentally unhide elements with the
265
+ * [hidden] attribute while still maintaining the until-found
266
+ * functionality.
267
+ */
268
+ [hidden]:not([hidden="until-found"]) {
269
+ display: none !important;
270
+ }
271
+
272
+ /**
273
+ * Turn images into block elements
274
+ */
275
+ img {
276
+ display: block;
277
+ }
278
+
279
+ /**
280
+ * Change cursor of <summary>
281
+ *
282
+ * By default, only the ::marker inside the summary uses the
283
+ * default cursor.
284
+ */
285
+ summary {
286
+ cursor: default;
287
+ }
288
+
289
+ /**
290
+ * Remove the default border from iframes
291
+ */
292
+ iframe {
293
+ border: none;
294
+ }
295
+
296
+
297
+ /**
298
+ * By default popovers look like modals without a backdrop.
299
+ * This makes use of the implicit anchor in popvers to position
300
+ * it closely to the trigger.
301
+ */
302
+ @supports(position-area: end) {
303
+ [popover] {
304
+ margin: 0;
305
+ position-area: end span-end;
306
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
307
+ }
308
+ }
309
+ }