@classic-homes/theme-tailwind-preset 0.7.0 → 0.9.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 +6 -0
- package/index.js +42 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,3 +32,9 @@ Dark mode is enabled with a `dark` class on `<html>`.
|
|
|
32
32
|
## Exports
|
|
33
33
|
|
|
34
34
|
The package has one entry, `@classic-homes/theme-tailwind-preset`, which exports the preset object (CommonJS `module.exports`; `import` works through Node's CJS interop).
|
|
35
|
+
|
|
36
|
+
## Touch and narrow-screen helpers
|
|
37
|
+
|
|
38
|
+
- **`tap-target`**: grows an element's hit area to at least 44×44px on coarse pointers (touch) with a centred, invisible `::after`. Layout and visuals don't change. Use it on small icon buttons, chip removers and inline text buttons. It sets `position: relative` unless the element is `absolute`/`fixed`/`sticky`, and it uses `::after`, so don't combine it with other `after:` utilities.
|
|
39
|
+
- **Base resets**: `fieldset { min-width: 0 }` (fieldsets default to min-content width and push phone layouts sideways). On coarse pointers, `<summary>` gets `0.5rem` vertical padding (padding utilities still win).
|
|
40
|
+
- **`--fab-bottom-inset`** (consumed by theme-svelte's `FloatingActionButton` and DataPanel launchers): set it on `:root` while a bottom bar is showing, and a bottom-corner launcher sits above it.
|
package/index.js
CHANGED
|
@@ -75,6 +75,47 @@ function headingBase({ addBase, theme }) {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* `tap-target`: grows an element's hit area to at least 44×44px on coarse pointers
|
|
80
|
+
* (touch) with a centred, invisible ::after — layout and visuals don't change.
|
|
81
|
+
* For small icon buttons, chip removers, inline text buttons and sort headers.
|
|
82
|
+
*
|
|
83
|
+
* - Sets `position: relative` unless the element is already `absolute`/`fixed`/`sticky`.
|
|
84
|
+
* - Uses `::after`: don't combine with other `after:` utilities on the same element.
|
|
85
|
+
* - Neighbouring targets closer than 44px will overlap; the later one in the DOM wins.
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Base resets preflight leaves out that break narrow layouts and touch:
|
|
89
|
+
* - fieldset defaults to `min-inline-size: min-content`, so a fieldset holding a wide row
|
|
90
|
+
* (columns editor, radio grid) refuses to shrink and pushes the page sideways on phones.
|
|
91
|
+
* - <summary> toggles get vertical padding on coarse pointers.
|
|
92
|
+
*/
|
|
93
|
+
function responsiveBase({ addBase }) {
|
|
94
|
+
addBase({
|
|
95
|
+
fieldset: { minWidth: '0' },
|
|
96
|
+
// <details> toggles are usually one text line (16–20px); on touch give them a
|
|
97
|
+
// 36px+ row. Padding utilities on the summary still win (utilities layer).
|
|
98
|
+
'@media (pointer: coarse)': { summary: { paddingTop: '0.5rem', paddingBottom: '0.5rem' } },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function tapTarget({ addUtilities }) {
|
|
103
|
+
addUtilities({
|
|
104
|
+
'.tap-target:not(.absolute):not(.fixed):not(.sticky)': { position: 'relative' },
|
|
105
|
+
'@media (pointer: coarse)': {
|
|
106
|
+
'.tap-target::after': {
|
|
107
|
+
content: "''",
|
|
108
|
+
position: 'absolute',
|
|
109
|
+
top: '50%',
|
|
110
|
+
left: '50%',
|
|
111
|
+
width: 'max(100%, 44px)',
|
|
112
|
+
height: 'max(100%, 44px)',
|
|
113
|
+
transform: 'translate(-50%, -50%)',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
78
119
|
/** @type {import('tailwindcss').Config} */
|
|
79
120
|
module.exports = {
|
|
80
121
|
// Enable dark mode via class on <html> element
|
|
@@ -441,5 +482,5 @@ module.exports = {
|
|
|
441
482
|
},
|
|
442
483
|
},
|
|
443
484
|
},
|
|
444
|
-
plugins: [headingBase],
|
|
485
|
+
plugins: [headingBase, responsiveBase, tapTarget],
|
|
445
486
|
};
|