@obosbbl/grunnmuren-tailwind 0.1.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/LICENSE +21 -0
- package/README.md +19 -0
- package/package.json +27 -0
- package/tailwind-base.cjs +338 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 OBOS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @obosbbl/grunnmuren-tailwind
|
|
2
|
+
|
|
3
|
+
Grunnmuren Tailwind preset.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -D @obosbbl/grunnmuren-tailwind tailwindcss
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
// tailwind.config.js
|
|
15
|
+
module.exports = {
|
|
16
|
+
presets: [require('@obosbbl/grunnmuren-tailwind')],
|
|
17
|
+
// ...
|
|
18
|
+
};
|
|
19
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@obosbbl/grunnmuren-tailwind",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Grunnmuren Tailwind preset",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/code-obos/grunnmuren",
|
|
9
|
+
"directory": "packages/tailwind"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./tailwind-base.cjs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"tailwind-base.cjs"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@tailwindcss/aspect-ratio": "0.4.0",
|
|
19
|
+
"@tailwindcss/typography": "0.5.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tailwindcss": "3.0.24"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"tailwindcss": "^3"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
const plugin = require('tailwindcss/plugin');
|
|
2
|
+
|
|
3
|
+
// naively assume all fonts are hosted at the following paths at the root of the app
|
|
4
|
+
const fonts = [
|
|
5
|
+
{
|
|
6
|
+
fontWeight: 400,
|
|
7
|
+
fontStyle: 'normal',
|
|
8
|
+
url: '/fonts/gorditaregular-webfont.woff2',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
fontWeight: 400,
|
|
12
|
+
fontStyle: 'italic',
|
|
13
|
+
url: '/fonts/gorditaregularitalic-webfont.woff2',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
fontWeight: 500,
|
|
17
|
+
fontStyle: 'normal',
|
|
18
|
+
url: '/fonts/gorditamedium-webfont.woff2',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
fontWeight: 700,
|
|
22
|
+
fontStyle: 'normal',
|
|
23
|
+
url: '/fonts/gorditabold-webfont.woff2',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const button = plugin(function ({ addComponents }) {
|
|
28
|
+
// adds a shade on the button when hovered
|
|
29
|
+
// ideally this would be solved by just darkening the button background,
|
|
30
|
+
// but that doesn't really work since some of the button variations have transparent backgrounds
|
|
31
|
+
addComponents({
|
|
32
|
+
'.gm-button': {
|
|
33
|
+
'&::after': {
|
|
34
|
+
content: '""',
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
backgroundColor: 'transparent',
|
|
37
|
+
display: 'block',
|
|
38
|
+
top: '-2px',
|
|
39
|
+
left: '-2px',
|
|
40
|
+
right: '-2px',
|
|
41
|
+
bottom: '-2px',
|
|
42
|
+
borderRadius: '0.75rem',
|
|
43
|
+
},
|
|
44
|
+
'&:hover::after': {
|
|
45
|
+
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
46
|
+
borderRadius: '0.375rem',
|
|
47
|
+
transition: 'all 200ms cubic-bezier(0.4, 0, 0.2, 1)',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const checkbox = plugin(function ({ addComponents }) {
|
|
54
|
+
addComponents({
|
|
55
|
+
'.gm-checkbox': {
|
|
56
|
+
'&::before': {
|
|
57
|
+
content: '""',
|
|
58
|
+
width: '0.65em',
|
|
59
|
+
height: '0.65em',
|
|
60
|
+
transform: 'scale(0)',
|
|
61
|
+
transition: '120ms transform ease-in-out',
|
|
62
|
+
'box-shadow': 'inset 1em 1em currentColor',
|
|
63
|
+
'clip-path':
|
|
64
|
+
'polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%)',
|
|
65
|
+
},
|
|
66
|
+
'&:checked::before': {
|
|
67
|
+
transform: 'scale(1)',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const headings = plugin(function ({ addBase, addComponents }) {
|
|
74
|
+
const h1 = '@apply font-bold text-3xl md:text-5xl';
|
|
75
|
+
const h2 = '@apply font-bold text-2xl md:text-4xl';
|
|
76
|
+
const h3 = '@apply font-bold text-xl md:text-2xl';
|
|
77
|
+
const h4 = '@apply font-bold text-lg md:text-xl';
|
|
78
|
+
|
|
79
|
+
addBase({
|
|
80
|
+
h1: {
|
|
81
|
+
[h1]: {},
|
|
82
|
+
},
|
|
83
|
+
h2: {
|
|
84
|
+
[h2]: {},
|
|
85
|
+
},
|
|
86
|
+
h3: {
|
|
87
|
+
[h3]: {},
|
|
88
|
+
},
|
|
89
|
+
h4: {
|
|
90
|
+
[h4]: {},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
addComponents({
|
|
95
|
+
'.gm-h1': {
|
|
96
|
+
[h1]: {},
|
|
97
|
+
},
|
|
98
|
+
'.gm-h2': {
|
|
99
|
+
[h2]: {},
|
|
100
|
+
},
|
|
101
|
+
'.gm-h3': {
|
|
102
|
+
[h3]: {},
|
|
103
|
+
},
|
|
104
|
+
'.gm-h4': {
|
|
105
|
+
[h4]: {},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const snackbar = plugin(function ({ addComponents, theme }) {
|
|
111
|
+
addComponents({
|
|
112
|
+
'.gm-snackbar': {
|
|
113
|
+
'grid-template-columns': 'min-content auto',
|
|
114
|
+
'grid-template-areas': '"icon header" ". content" "actions actions"',
|
|
115
|
+
},
|
|
116
|
+
[`@media(min-width: ${theme('screens.md')})`]: {
|
|
117
|
+
'.gm-snackbar': {
|
|
118
|
+
'grid-template-columns': 'min-content auto auto',
|
|
119
|
+
'grid-template-areas': '"icon header actions" ". content content"',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
'.gm-snackbar-icon': {
|
|
123
|
+
'grid-area': 'icon',
|
|
124
|
+
},
|
|
125
|
+
'.gm-snackbar-header': {
|
|
126
|
+
'grid-area': 'header',
|
|
127
|
+
},
|
|
128
|
+
'.gm-snackbar-content': {
|
|
129
|
+
'grid-area': 'content',
|
|
130
|
+
},
|
|
131
|
+
'.gm-snackbar-actions': {
|
|
132
|
+
'grid-area': 'actions',
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
module.exports = {
|
|
138
|
+
plugins: [
|
|
139
|
+
// TODO: Remove the aspect ratio plugin when Safari 14 usage is low enough
|
|
140
|
+
require('@tailwindcss/aspect-ratio'),
|
|
141
|
+
require('@tailwindcss/typography'),
|
|
142
|
+
button,
|
|
143
|
+
headings,
|
|
144
|
+
checkbox,
|
|
145
|
+
snackbar,
|
|
146
|
+
plugin(function ({ addBase, addUtilities, addComponents }) {
|
|
147
|
+
addBase({
|
|
148
|
+
html: {
|
|
149
|
+
'@apply text-black antialiased font-normal': {},
|
|
150
|
+
},
|
|
151
|
+
b: {
|
|
152
|
+
fontWeight: 500,
|
|
153
|
+
},
|
|
154
|
+
strong: {
|
|
155
|
+
fontWeight: 500,
|
|
156
|
+
},
|
|
157
|
+
a: {
|
|
158
|
+
'@apply underline': {},
|
|
159
|
+
},
|
|
160
|
+
'::selection': { '@apply bg-green-light text-black': {} },
|
|
161
|
+
});
|
|
162
|
+
addComponents({
|
|
163
|
+
'.container': {
|
|
164
|
+
width: '100%',
|
|
165
|
+
paddingLeft: '1rem',
|
|
166
|
+
paddingRight: '1rem',
|
|
167
|
+
marginLeft: 'auto',
|
|
168
|
+
marginRight: 'auto',
|
|
169
|
+
maxWidth: '90rem',
|
|
170
|
+
},
|
|
171
|
+
'.container-prose': {
|
|
172
|
+
width: '100%',
|
|
173
|
+
paddingLeft: '1rem',
|
|
174
|
+
paddingRight: '1rem',
|
|
175
|
+
marginLeft: 'auto',
|
|
176
|
+
marginRight: 'auto',
|
|
177
|
+
maxWidth: '37rem',
|
|
178
|
+
},
|
|
179
|
+
// that thin blue line at the top
|
|
180
|
+
'.gm-topline::before': {
|
|
181
|
+
display: 'block',
|
|
182
|
+
width: '100%',
|
|
183
|
+
height: '5px',
|
|
184
|
+
content: '""',
|
|
185
|
+
position: 'fixed',
|
|
186
|
+
left: '0',
|
|
187
|
+
top: '0',
|
|
188
|
+
right: '0',
|
|
189
|
+
// FIXME: Not sure why this doesn't work
|
|
190
|
+
//backgroundColor: theme('colors.blue'),
|
|
191
|
+
backgroundColor: '#0047BA',
|
|
192
|
+
zIndex: '100',
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* Round the corners of our main content.
|
|
196
|
+
* Protip: Use this together with navbar, footer and `bg-blue` class on the body.
|
|
197
|
+
*/
|
|
198
|
+
'.gm-pagemain': {
|
|
199
|
+
backgroundColor: '#fff',
|
|
200
|
+
borderRadius: '2rem',
|
|
201
|
+
overflow: 'hidden',
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
addUtilities({
|
|
205
|
+
// imitates a bold font, but doesn't cause layout due to element width change like with font-weight
|
|
206
|
+
// Note that this CSS isn't standardized, but it works in Fx, Chrome, Safari and Edge
|
|
207
|
+
'.fake-font-bold': {
|
|
208
|
+
'-webkit-text-stroke': '1px',
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}),
|
|
212
|
+
plugin(function ({ addBase }) {
|
|
213
|
+
addBase(
|
|
214
|
+
fonts.map((font) => ({
|
|
215
|
+
'@font-face': {
|
|
216
|
+
fontFamily: 'Gordita',
|
|
217
|
+
fontWeight: font.fontWeight,
|
|
218
|
+
fontStyle: font.fontStyle,
|
|
219
|
+
src: `url('${font.url}') format('woff2')`,
|
|
220
|
+
fontDisplay: 'swap',
|
|
221
|
+
},
|
|
222
|
+
})),
|
|
223
|
+
);
|
|
224
|
+
}),
|
|
225
|
+
],
|
|
226
|
+
corePlugins: {
|
|
227
|
+
container: false,
|
|
228
|
+
},
|
|
229
|
+
theme: {
|
|
230
|
+
fontSize: {
|
|
231
|
+
sm: '0.875rem',
|
|
232
|
+
base: '1rem',
|
|
233
|
+
lg: '1.125rem', // 18px
|
|
234
|
+
xl: '1.25rem', // 20px
|
|
235
|
+
'2xl': '1.5rem', // 24px
|
|
236
|
+
'3xl': '1.875rem', // 28px
|
|
237
|
+
'4xl': '2rem', // 32px
|
|
238
|
+
'5xl': '2.5rem', // 40px
|
|
239
|
+
},
|
|
240
|
+
extend: {
|
|
241
|
+
maxWidth: {
|
|
242
|
+
// Override Tailwinds default prose width of 60 chars to 48. Roughly 590 pixels
|
|
243
|
+
prose: '48ch',
|
|
244
|
+
},
|
|
245
|
+
width: {
|
|
246
|
+
prose: '48ch',
|
|
247
|
+
},
|
|
248
|
+
screens: {
|
|
249
|
+
// replicate the smaller than breakpoint from Windi. Even though we are mobile first, it is really nice with an escape hatch sometimes
|
|
250
|
+
'<md': { max: '767.9px' },
|
|
251
|
+
},
|
|
252
|
+
spacing: {
|
|
253
|
+
18: '4.5rem',
|
|
254
|
+
},
|
|
255
|
+
colors: {
|
|
256
|
+
black: '#333',
|
|
257
|
+
white: '#fff',
|
|
258
|
+
gray: {
|
|
259
|
+
// TODO: Figure out how to work this into the color scale
|
|
260
|
+
concrete: '#f1f1f1',
|
|
261
|
+
// Gray
|
|
262
|
+
dark: '#595959',
|
|
263
|
+
// Medium gray
|
|
264
|
+
DEFAULT: '#818181',
|
|
265
|
+
// Light gray
|
|
266
|
+
light: '#E6E6E6',
|
|
267
|
+
},
|
|
268
|
+
blue: {
|
|
269
|
+
// light blue
|
|
270
|
+
lightest: '#DEEFF5',
|
|
271
|
+
// OBOS Sky
|
|
272
|
+
light: '#BEDFEC',
|
|
273
|
+
// OBOS Blue/Primary brand
|
|
274
|
+
DEFAULT: '#0047BA',
|
|
275
|
+
// OBOS Ocean
|
|
276
|
+
dark: '#002169',
|
|
277
|
+
},
|
|
278
|
+
green: {
|
|
279
|
+
// light green
|
|
280
|
+
lightest: '#E6F5F0',
|
|
281
|
+
// OBOS Mint
|
|
282
|
+
light: '#CDECE2',
|
|
283
|
+
// OBOS Green/Primary brand
|
|
284
|
+
DEFAULT: '#008761',
|
|
285
|
+
// OBOS Forest
|
|
286
|
+
dark: '#00524C',
|
|
287
|
+
},
|
|
288
|
+
red: {
|
|
289
|
+
// error red
|
|
290
|
+
light: '#faedef',
|
|
291
|
+
DEFAULT: '#cd465e',
|
|
292
|
+
},
|
|
293
|
+
orange: {
|
|
294
|
+
light: '#f8e5c9',
|
|
295
|
+
DEFAULT: '#e8a74a',
|
|
296
|
+
},
|
|
297
|
+
yellow: {
|
|
298
|
+
// open house
|
|
299
|
+
DEFAULT: '#fff5d2',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
fontFamily: {
|
|
303
|
+
sans: ['Gordita', 'sans-serif'],
|
|
304
|
+
},
|
|
305
|
+
boxShadow: {
|
|
306
|
+
DEFAULT: '0 6px 4px 0 rgba(0, 33, 105, 0.25)',
|
|
307
|
+
},
|
|
308
|
+
typography: (theme) => ({
|
|
309
|
+
DEFAULT: {
|
|
310
|
+
css: {
|
|
311
|
+
'--tw-prose-headings': theme('colors.black'),
|
|
312
|
+
'--tw-prose-lead': theme('colors.black'),
|
|
313
|
+
color: theme('colors.black'),
|
|
314
|
+
maxWidth: '48ch',
|
|
315
|
+
a: {
|
|
316
|
+
fontWeight: 400,
|
|
317
|
+
},
|
|
318
|
+
h1: {
|
|
319
|
+
fontWeight: 'bold',
|
|
320
|
+
},
|
|
321
|
+
h2: {
|
|
322
|
+
fontWeight: 'bold',
|
|
323
|
+
},
|
|
324
|
+
h3: {
|
|
325
|
+
fontWeight: 'bold',
|
|
326
|
+
},
|
|
327
|
+
h4: {
|
|
328
|
+
fontWeight: 'bold',
|
|
329
|
+
},
|
|
330
|
+
'[class~="lead"]': {
|
|
331
|
+
fontWeight: 500,
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
}),
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
};
|