@obosbbl/grunnmuren-tailwind 0.4.2 → 0.6.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/tailwind-base.cjs +82 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-tailwind",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "Grunnmuren Tailwind preset",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -16,10 +16,10 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@tailwindcss/aspect-ratio": "0.4.0",
19
- "@tailwindcss/typography": "0.5.2"
19
+ "@tailwindcss/typography": "0.5.4"
20
20
  },
21
21
  "devDependencies": {
22
- "tailwindcss": "3.1.4"
22
+ "tailwindcss": "3.1.8"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "tailwindcss": "^3"
package/tailwind-base.cjs CHANGED
@@ -47,12 +47,34 @@ const obosFonts = [
47
47
  },
48
48
  ];
49
49
 
50
- const button = plugin(function ({ addComponents }) {
51
- // adds a shade on the button when hovered
52
- // ideally this would be solved by just darkening the button background,
53
- // but that doesn't really work since some of the button variations have transparent backgrounds
50
+ const button = plugin(function ({ addComponents, theme }) {
51
+ const hoverLoadingBgColor = 'rgba(0, 0, 0, 0.1)';
52
+
54
53
  addComponents({
55
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
+ },
56
78
  '&::after': {
57
79
  content: '""',
58
80
  position: 'absolute',
@@ -62,12 +84,63 @@ const button = plugin(function ({ addComponents }) {
62
84
  left: '-2px',
63
85
  right: '-2px',
64
86
  bottom: '-2px',
65
- borderRadius: '0.75rem',
87
+ borderRadius: 'inherit',
66
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
67
92
  '&:hover::after': {
68
- backgroundColor: 'rgba(0, 0, 0, 0.1)',
69
- borderRadius: '0.375rem',
70
- transition: 'all 200ms cubic-bezier(0.4, 0, 0.2, 1)',
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
+ marginRight: '0.75rem',
120
+ // use grid to handle the checked:before styles
121
+ display: 'inline-grid',
122
+ placeContent: 'center',
123
+ '&:checked': {
124
+ borderColor: theme('colors.green.DEFAULT'),
125
+ },
126
+ '&:focus-visible': {
127
+ outline: '1px solid currentColor',
128
+ outlineOffset: '4px',
129
+ },
130
+ '&::before': {
131
+ content: '""',
132
+ display: 'block',
133
+ borderRadius: '50%',
134
+ transform: 'scale(0)',
135
+ width: '0.65em',
136
+ height: '0.65em',
137
+ transition: '120ms transform ease-in-out',
138
+ boxShadow: `inset 1em 1em ${theme('colors.green.DEFAULT')}`,
139
+ /* Windows High Contrast Mode */
140
+ backgroundColor: 'CanvasText',
141
+ },
142
+ '&:checked::before': {
143
+ transform: 'scale(1)',
71
144
  },
72
145
  },
73
146
  });
@@ -187,6 +260,7 @@ module.exports = (userOptions) => {
187
260
  headings,
188
261
  checkbox,
189
262
  snackbar,
263
+ radio,
190
264
  plugin(function ({ addBase, addUtilities, addComponents, theme }) {
191
265
  addBase({
192
266
  html: {