@obosbbl/grunnmuren-tailwind 0.9.1 → 2.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 OBOS
3
+ Copyright (c) 2023 OBOS
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -23,26 +23,4 @@ module.exports = {
23
23
  './src/components/**/*.{ts,tsx}',
24
24
  ],
25
25
  };
26
-
27
- // Usage with options
28
- module.exports = {
29
- presets: [require('@obosbbl/grunnmuren-tailwind')({ useLegacyFont: true, fontBasePath: '/mypath/myfonts' }),
30
- // content: [ ... ]
31
- };
32
26
  ```
33
-
34
- ### Fonts
35
-
36
- The preset includes font declarations.
37
- You'll have to setup your app so it serves the necessary [font files](../react/public/fonts/).
38
- By default the fonts should be under `/fonts/` but you can override this with the config option `fontBasePath`.
39
- See the [preset implementation](./tailwind-base.cjs).
40
-
41
- ## Options
42
-
43
- The preset supports the following options:
44
-
45
- | Name | Default value | Description |
46
- | ------------- | ------------- | -------------------------------------------- |
47
- | useLegacyFont | `false` | Whether to use the fonts from the old design |
48
- | fontBasePath | `/fonts` | Path to where the fonts are hosted |
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-tailwind",
3
- "version": "0.9.1",
3
+ "version": "2.0.0",
4
4
  "description": "Grunnmuren Tailwind preset",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
7
7
  "repository": {
8
- "url": "https://github.com/code-obos/grunnmuren",
9
- "directory": "packages/tailwind"
8
+ "url": "https://github.com/code-obos/grunnmuren"
10
9
  },
11
10
  "exports": {
12
11
  ".": "./tailwind-base.cjs"
@@ -14,15 +13,11 @@
14
13
  "files": [
15
14
  "tailwind-base.cjs"
16
15
  ],
17
- "dependencies": {
18
- "@tailwindcss/aspect-ratio": "0.4.2",
19
- "@tailwindcss/typography": "0.5.9"
20
- },
16
+ "dependencies": {},
21
17
  "devDependencies": {
22
- "tailwindcss": "3.3.2",
23
- "postcss": "8.4.23"
18
+ "tailwindcss": "3.3.4"
24
19
  },
25
20
  "peerDependencies": {
26
- "tailwindcss": "^3.2"
21
+ "tailwindcss": "^3.4"
27
22
  }
28
23
  }
package/tailwind-base.cjs CHANGED
@@ -1,270 +1,35 @@
1
1
  const plugin = require('tailwindcss/plugin');
2
2
 
3
- // naively assume all fonts are hosted at the following paths at the root of the app
4
- const gorditaFonts = [
5
- {
6
- fontWeight: 400,
7
- fontStyle: 'normal',
8
- url: '/gorditaregular-webfont.woff2',
9
- },
10
- {
11
- fontWeight: 400,
12
- fontStyle: 'italic',
13
- url: '/gorditaregularitalic-webfont.woff2',
14
- },
15
- {
16
- fontWeight: 500,
17
- fontStyle: 'normal',
18
- url: '/gorditamedium-webfont.woff2',
19
- },
20
- {
21
- fontWeight: 700,
22
- fontStyle: 'normal',
23
- url: '/gorditabold-webfont.woff2',
24
- },
25
- ];
26
-
27
3
  const obosFonts = [
28
4
  {
29
5
  fontWeight: 400,
30
6
  fontStyle: 'normal',
31
- url: '/OBOSText-Regular.woff2',
7
+ url: 'https://www.obos.no/fonts/OBOSText-Regular.woff2',
32
8
  },
33
9
  {
34
10
  fontWeight: 400,
35
11
  fontStyle: 'italic',
36
- url: '/OBOSText-Italic.woff2',
12
+ url: 'https://www.obos.no/fonts/OBOSText-Italic.woff2',
37
13
  },
38
14
  {
39
15
  fontWeight: 500,
40
16
  fontStyle: 'normal',
41
- url: '/OBOSText-Medium.woff2',
17
+ url: 'https://www.obos.no/fonts/OBOSText-Medium.woff2',
42
18
  },
43
19
  {
44
20
  fontWeight: 700,
45
21
  fontStyle: 'normal',
46
- url: '/OBOSText-Bold.woff2',
22
+ url: 'https://www.obos.no/fonts/OBOSText-Bold.woff2',
47
23
  },
48
24
  ];
49
25
 
50
- const button = plugin(function ({ addComponents, theme }) {
51
- const hoverLoadingBgColor = 'rgba(0, 0, 0, 0.1)';
52
-
53
- addComponents({
54
- '.button': {
55
- // The Tailwind utilities we use for focus styling are kinda hard to "translate", so using the @apply utility here, even though mixing styles are meh...
56
- '@apply focus:outline-none focus-visible:ring-2 focus-visible:ring-black ring-offset-2':
57
- {},
58
- position: 'relative',
59
- textDecorationLine: 'none',
60
- display: 'inline-flex',
61
- alignItems: 'center',
62
- gap: theme('spacing.3'),
63
- border: '2px solid',
64
- padding: `${theme('spacing.2')} ${theme('spacing.6')}`,
65
- borderRadius: '0.75rem',
66
- transition: `all 200ms ${theme('transitionTimingFunction.DEFAULT')}`,
67
- fontWeight: theme('fontWeight.medium'),
68
- width: 'fit-content',
69
- '&:disabled': {
70
- backgroundColor: theme('colors.gray.light'),
71
- borderColor: theme('colors.gray.light'),
72
- color: theme('colors.black'),
73
- pointerEvents: 'none',
74
- },
75
- '&:hover': {
76
- borderRadius: '0.375rem',
77
- },
78
- '&::after': {
79
- content: '""',
80
- position: 'absolute',
81
- backgroundColor: 'transparent',
82
- display: 'block',
83
- top: '-2px',
84
- left: '-2px',
85
- right: '-2px',
86
- bottom: '-2px',
87
- borderRadius: 'inherit',
88
- },
89
- // adds a shade on the button when hovered
90
- // ideally this would be solved by just darkening the button background,
91
- // but that doesn't really work since some of the button variations have transparent backgrounds
92
- '&:hover::after': {
93
- backgroundColor: hoverLoadingBgColor,
94
- transition: `all 200ms ${theme('transitionTimingFunction.DEFAULT')}`,
95
- },
96
- // We use aria-busy to indicate loading state
97
- '&[aria-busy="true"] > *': {
98
- visibility: 'hidden',
99
- },
100
- '&[aria-busy="true"]::after': {
101
- backgroundColor: hoverLoadingBgColor,
102
- },
103
- },
104
- });
105
- });
106
-
107
- const radio = plugin(function ({ addComponents, theme }) {
108
- addComponents({
109
- '.radio': {
110
- // hide the native radio input
111
- appearance: 'none',
112
- // not removed via appeareance
113
- margin: 0,
114
- height: '1.25rem',
115
- width: '1.25rem',
116
- borderRadius: '50%',
117
- border: `2px solid ${theme('colors.gray.dark')}`,
118
- cursor: 'pointer',
119
- // use grid to handle the checked:before styles
120
- display: 'inline-grid',
121
- placeContent: 'center',
122
- // Prevent flex container from altering the size of the radio button
123
- flex: '0 0 auto',
124
- // magic number that tries to keep the input horizontally centered in relation to the first line of the label text
125
- transform: 'translateY(0.095em)',
126
- '&:checked': {
127
- borderColor: theme('colors.green.DEFAULT'),
128
- },
129
- '&:focus-visible': {
130
- outline: '1px solid currentColor',
131
- outlineOffset: '4px',
132
- },
133
- '&::before': {
134
- content: '""',
135
- display: 'block',
136
- borderRadius: '50%',
137
- transform: 'scale(0)',
138
- width: '0.65em',
139
- height: '0.65em',
140
- transition: '120ms transform ease-in-out',
141
- boxShadow: `inset 1em 1em ${theme('colors.green.DEFAULT')}`,
142
- /* Windows High Contrast Mode */
143
- backgroundColor: 'CanvasText',
144
- },
145
- '&:checked::before': {
146
- transform: 'scale(1)',
147
- },
148
- },
149
- });
150
- });
151
-
152
- const checkbox = plugin(function ({ addComponents, theme }) {
153
- addComponents({
154
- '.checkbox': {
155
- '&::before': {
156
- content: '""',
157
- width: '0.65em',
158
- height: '0.65em',
159
- transform: 'scale(0)',
160
- transition: '120ms transform ease-in-out',
161
- backgroundColor: theme('colors.white'),
162
- 'box-shadow': 'inset 1em 1em currentColor',
163
- 'clip-path':
164
- 'polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%)',
165
- },
166
- '&:checked::before': {
167
- transform: 'scale(1)',
168
- },
169
- },
170
- });
171
- });
172
-
173
- const headings = plugin(function ({ addBase, addComponents }) {
174
- const h1 = '@apply font-bold text-3xl md:text-5xl';
175
- const h2 = '@apply font-bold text-2xl md:text-4xl';
176
- const h3 = '@apply font-bold text-xl md:text-2xl';
177
- const h4 = '@apply font-bold text-lg md:text-xl';
178
-
179
- addBase({
180
- h1: {
181
- [h1]: {},
182
- },
183
- h2: {
184
- [h2]: {},
185
- },
186
- h3: {
187
- [h3]: {},
188
- },
189
- h4: {
190
- [h4]: {},
191
- },
192
- });
193
-
194
- addComponents({
195
- '.h1': {
196
- [h1]: {},
197
- },
198
- '.h2': {
199
- [h2]: {},
200
- },
201
- '.h3': {
202
- [h3]: {},
203
- },
204
- '.h4': {
205
- [h4]: {},
206
- },
207
- });
208
- });
209
-
210
- const snackbar = plugin(function ({ addComponents, theme }) {
211
- addComponents({
212
- '.snackbar': {
213
- 'grid-template-columns': 'min-content auto',
214
- 'grid-template-areas': '"icon header" ". content" "actions actions"',
215
- },
216
- [`@media(min-width: ${theme('screens.md')})`]: {
217
- '.snackbar': {
218
- 'grid-template-columns': 'min-content auto auto',
219
- 'grid-template-areas': '"icon header actions" ". content content"',
220
- },
221
- },
222
- '.snackbar-icon': {
223
- 'grid-area': 'icon',
224
- },
225
- '.snackbar-header': {
226
- 'grid-area': 'header',
227
- },
228
- '.snackbar-content': {
229
- 'grid-area': 'content',
230
- },
231
- '.snackbar-actions': {
232
- 'grid-area': 'actions',
233
- },
234
- });
235
- });
236
-
237
- const defaultOpts = {
238
- useLegacyFont: false,
239
- fontBasePath: '/fonts',
240
- useLegacyContainerSize: false,
241
- };
242
-
243
- module.exports = (userOptions) => {
244
- const opts = userOptions ? { ...defaultOpts, ...userOptions } : defaultOpts;
245
- let fontFamily = 'OBOSFont';
246
- let fonts = obosFonts;
247
- let containerSize = '92rem';
248
- if (opts.useLegacyFont) {
249
- fontFamily = 'Gordita';
250
- fonts = gorditaFonts;
251
- }
252
-
253
- if (opts.useLegacyContainerSize) {
254
- containerSize = '82rem';
255
- }
26
+ module.exports = () => {
27
+ const fontFamily = 'OBOSFont';
28
+ const fonts = obosFonts;
256
29
 
257
30
  return {
258
31
  plugins: [
259
- // TODO: Remove the aspect ratio plugin when Safari 14 usage is low enough
260
- require('@tailwindcss/aspect-ratio'),
261
- require('@tailwindcss/typography'),
262
- button,
263
- headings,
264
- checkbox,
265
- snackbar,
266
- radio,
267
- plugin(function ({ addBase, addUtilities, addComponents, theme }) {
32
+ plugin(function ({ addBase }) {
268
33
  addBase({
269
34
  html: {
270
35
  '@apply text-black antialiased font-normal': {},
@@ -275,73 +40,7 @@ module.exports = (userOptions) => {
275
40
  strong: {
276
41
  fontWeight: 500,
277
42
  },
278
- a: {
279
- '@apply underline': {},
280
- },
281
43
  '::selection': { '@apply bg-mint text-black': {} },
282
- // Remove the disclosure triangle in Safari if apply the `list-none` utility to the summary element
283
- 'summary.list-none::-webkit-details-marker': {
284
- display: 'none',
285
- },
286
- });
287
- addComponents({
288
- '.container': {
289
- width: '100%',
290
- paddingLeft: '1rem',
291
- paddingRight: '1rem',
292
- marginLeft: 'auto',
293
- marginRight: 'auto',
294
- maxWidth: containerSize,
295
- },
296
- '.container-prose': {
297
- width: '100%',
298
- paddingLeft: '1rem',
299
- paddingRight: '1rem',
300
- marginLeft: 'auto',
301
- marginRight: 'auto',
302
- maxWidth: '45.5rem',
303
- },
304
- // that thin blue line at the top
305
- '.topline::before': {
306
- display: 'block',
307
- width: '100%',
308
- height: '5px',
309
- content: '""',
310
- position: 'fixed',
311
- left: '0',
312
- top: '0',
313
- right: '0',
314
- backgroundColor: theme('colors.blue.DEFAULT'),
315
- zIndex: '100',
316
- },
317
- /**
318
- * @deprecated use page-layout and page-layout-main instead
319
- */
320
- '.pagemain': {
321
- backgroundColor: '#fff',
322
- borderRadius: '1.5rem',
323
- overflow: 'hidden',
324
- },
325
-
326
- '.page-layout': {
327
- display: 'flex',
328
- flexDirection: 'column',
329
- minHeight: '100vh',
330
- },
331
- '.page-layout-main': {
332
- backgroundColor: '#fff',
333
- flexGrow: '1',
334
- },
335
- });
336
- addUtilities({
337
- // imitates a bold font, but doesn't cause layout due to element width change like with font-weight
338
- // Note that this CSS isn't standardized, but it works in Fx, Chrome, Safari and Edge
339
- /**
340
- * @deprecated use font-bold instead
341
- */
342
- '.fake-font-bold': {
343
- '-webkit-text-stroke': '1px',
344
- },
345
44
  });
346
45
  }),
347
46
  plugin(function ({ addBase }) {
@@ -351,181 +50,74 @@ module.exports = (userOptions) => {
351
50
  fontFamily,
352
51
  fontWeight: font.fontWeight,
353
52
  fontStyle: font.fontStyle,
354
- src: `url('${opts.fontBasePath}${font.url}') format('woff2')`,
53
+ src: `url('${font.url}') format('woff2')`,
355
54
  fontDisplay: 'swap',
356
55
  },
357
56
  })),
358
57
  );
359
58
  }),
360
59
  ],
361
- corePlugins: {
362
- container: false,
363
- },
364
60
  theme: {
365
- fontSize: {
366
- sm: '0.875rem',
367
- base: '1rem',
368
- lg: '1.125rem', // 18px
369
- xl: '1.25rem', // 20px
370
- '2xl': '1.5rem', // 24px
371
- '3xl': '1.875rem', // 28px
372
- '4xl': '2rem', // 32px
373
- '5xl': '2.5rem', // 40px
374
- },
375
- extend: {
376
- maxWidth: {
377
- // Override Tailwinds default prose width of 60 chars to 48. Roughly 590 pixels
378
- prose: '696px',
61
+ colors: {
62
+ black: '#333',
63
+ white: '#fff',
64
+ gray: {
65
+ DEFAULT: '#818181',
66
+ dark: '#595959',
67
+ light: '#E6E6E6',
68
+ lightest: '#f1f1f1',
379
69
  },
380
- width: {
381
- prose: '696px',
70
+ sky: {
71
+ DEFAULT: '#BEDFEC',
72
+ light: '#DEEFF5',
73
+ lightest: '#EBF5F9',
382
74
  },
383
- screens: {
384
- 'max-md': { max: '767.9px' },
385
- /**
386
- * @deprecated Tailwind 3.2 has built in support for max-width breakpoints, but it only works
387
- * with a "simple screens" configuration... We add `max-md` manually here, allow everyone to migrate off
388
- * `<md`, then we can remove `screens` enitrely from this config.
389
- */
390
- '<md': { max: '767.9px' },
75
+ mint: {
76
+ DEFAULT: '#CDECE2',
77
+ light: '#E6F5F0',
78
+ lightest: '#F0F9F6',
391
79
  },
392
- spacing: {
393
- 18: '4.5rem',
80
+ blue: {
81
+ // OBOS Blue/Primary brand
82
+ DEFAULT: '#0047BA',
83
+ light: '#BEDFEC',
84
+ lightest: '#DEEFF5',
85
+ // OBOS Ocean
86
+ dark: '#002169',
394
87
  },
395
- colors: {
396
- black: '#333',
397
- white: '#fff',
398
- gray: {
399
- // Dark Gray
400
- dark: '#595959',
401
- // gray
402
- DEFAULT: '#818181',
403
- // Light gray
404
- light: '#E6E6E6',
405
- // Lightest gray
406
- lightest: '#f1f1f1',
407
- // DEPRECATED concrete
408
- concrete: '#f1f1f1',
409
- },
410
- sky: {
411
- DEFAULT: '#BEDFEC',
412
- light: '#DEEFF5',
413
- lightest: '#EBF5F9',
414
- },
415
- mint: {
416
- DEFAULT: '#CDECE2',
417
- light: '#E6F5F0',
418
- lightest: '#F0F9F6',
419
- },
420
- blue: {
421
- // DEPRECATED light blue
422
- lightest: '#DEEFF5',
423
- // DEPRECATED OBOS Sky
424
- light: '#BEDFEC',
425
-
426
- // OBOS Blue/Primary brand
427
- DEFAULT: '#0047BA',
428
- // OBOS Ocean
429
- dark: '#002169',
430
- },
431
- green: {
432
- // DEPRECATED light green
433
- lightest: '#E6F5F0',
434
- // DEPRECATED OBOS Mint
435
- light: '#CDECE2',
436
-
437
- // OBOS Green/Primary brand
438
- DEFAULT: '#008761',
439
- // OBOS Forest
440
- dark: '#00524C',
441
- },
442
- red: {
443
- // error red
444
- light: '#faedef',
445
- DEFAULT: '#cd465e',
446
- },
447
- orange: {
448
- light: '#f8e5c9',
449
- DEFAULT: '#e8a74a',
450
- },
451
- yellow: {
452
- // open house
453
- DEFAULT: '#fff5d2',
454
- },
88
+ green: {
89
+ // OBOS Green/Primary brand
90
+ DEFAULT: '#008761',
91
+ lightest: '#E6F5F0',
92
+ light: '#CDECE2',
93
+ // OBOS Forest
94
+ dark: '#00524C',
455
95
  },
456
- borderColor: ({ theme }) => ({
457
- DEFAULT: theme('colors.gray.light', 'currentColor'),
458
- }),
459
- fontFamily: {
460
- sans: [fontFamily, 'sans-serif'],
96
+ red: {
97
+ DEFAULT: '#cd465e',
98
+ // error red
99
+ light: '#faedef',
461
100
  },
462
- boxShadow: {
463
- DEFAULT: '0 6px 4px 0 rgba(0, 33, 105, 0.25)',
101
+ orange: {
102
+ DEFAULT: '#e8a74a',
103
+ light: '#f8e5c9',
464
104
  },
465
- typography: (theme) => ({
466
- DEFAULT: {
467
- css: {
468
- '--tw-prose-headings': 'inherit',
469
- '--tw-prose-lead': 'inherit',
470
- '--tw-prose-links': 'inherit',
471
- '--tw-prose-quotes': theme('colors.blue.dark'),
472
- '--tw-prose-quote-borders': theme('colors.green.DEFAULT'),
473
- '--tw-prose-counters': theme('colors.black'),
474
- // TODO: Increase bullet size. See design sketches
475
- '--tw-prose-bullets': theme('colors.green.DEFAULT'),
476
- color: theme('colors.black'),
477
- maxWidth: theme('maxWidth.prose'),
478
- a: {
479
- fontWeight: 400,
480
- },
481
- h1: {
482
- fontWeight: theme('fontWeight.bold'),
483
- fontSize: theme('fontSize.3xl'),
484
- '@media (min-width: theme("screens.md"))': {
485
- fontSize: theme('fontSize.5xl'),
486
- },
487
- },
488
- h2: {
489
- fontWeight: theme('fontWeight.bold'),
490
- fontSize: theme('fontSize.2xl'),
491
- '@media (min-width: theme("screens.md"))': {
492
- fontSize: theme('fontSize.4xl'),
493
- },
494
- },
495
- h3: {
496
- fontWeight: theme('fontWeight.bold'),
497
- fontSize: theme('fontSize.xl'),
498
- '@media (min-width: theme("screens.md"))': {
499
- fontSize: theme('fontSize.2xl'),
500
- },
501
- },
502
- h4: {
503
- fontWeight: theme('fontWeight.bold'),
504
- fontSize: theme('fontSize.lg'),
505
- '@media (min-width: theme("screens.md"))': {
506
- fontSize: theme('fontSize.xl'),
507
- },
508
- },
509
- li: {
510
- marginTop: '1.5em',
511
- marginBottom: '1.5em',
512
- },
513
- blockquote: {
514
- fontWeight: theme('fontWeight.bold'),
515
- fontStyle: 'normal',
516
- },
517
- 'blockquote p:first-of-type::before': {
518
- content: '"«"',
519
- },
520
- 'blockquote p:last-of-type::after': {
521
- content: '"»"',
522
- },
523
- '[class~="lead"]': {
524
- fontWeight: theme('fontWeight.medium'),
525
- },
526
- },
527
- },
528
- }),
105
+ yellow: {
106
+ // open house
107
+ DEFAULT: '#fff5d2',
108
+ },
109
+ },
110
+ fontFamily: {
111
+ sans: [fontFamily, 'sans-serif'],
112
+ },
113
+ borderRadius: {
114
+ none: '0',
115
+ 'x-small': '0.5rem',
116
+ small: '1rem',
117
+ medium: '1.5rem',
118
+ large: '2rem',
119
+ 'x-large': '3rem',
120
+ 'xx-large': '3.5rem',
529
121
  },
530
122
  },
531
123
  };