Skip to content

Commit 5ee1eb4

Browse files
committed
Merge branch 'Larissagilliane-iss1074'
2 parents 28dab5e + bbe23fd commit 5ee1eb4

File tree

6 files changed

+203
-0
lines changed

6 files changed

+203
-0
lines changed

__tests__/fixtures/tailwind-output-important.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6865,6 +6865,18 @@ video {
68656865
stroke: currentColor !important;
68666866
}
68676867

6868+
.stroke-0 {
6869+
stroke-width: 0 !important;
6870+
}
6871+
6872+
.stroke-1 {
6873+
stroke-width: 1 !important;
6874+
}
6875+
6876+
.stroke-2 {
6877+
stroke-width: 2 !important;
6878+
}
6879+
68686880
.table-auto {
68696881
table-layout: auto !important;
68706882
}
@@ -16546,6 +16558,18 @@ video {
1654616558
stroke: currentColor !important;
1654716559
}
1654816560

16561+
.sm\:stroke-0 {
16562+
stroke-width: 0 !important;
16563+
}
16564+
16565+
.sm\:stroke-1 {
16566+
stroke-width: 1 !important;
16567+
}
16568+
16569+
.sm\:stroke-2 {
16570+
stroke-width: 2 !important;
16571+
}
16572+
1654916573
.sm\:table-auto {
1655016574
table-layout: auto !important;
1655116575
}
@@ -26228,6 +26252,18 @@ video {
2622826252
stroke: currentColor !important;
2622926253
}
2623026254

26255+
.md\:stroke-0 {
26256+
stroke-width: 0 !important;
26257+
}
26258+
26259+
.md\:stroke-1 {
26260+
stroke-width: 1 !important;
26261+
}
26262+
26263+
.md\:stroke-2 {
26264+
stroke-width: 2 !important;
26265+
}
26266+
2623126267
.md\:table-auto {
2623226268
table-layout: auto !important;
2623326269
}
@@ -35910,6 +35946,18 @@ video {
3591035946
stroke: currentColor !important;
3591135947
}
3591235948

35949+
.lg\:stroke-0 {
35950+
stroke-width: 0 !important;
35951+
}
35952+
35953+
.lg\:stroke-1 {
35954+
stroke-width: 1 !important;
35955+
}
35956+
35957+
.lg\:stroke-2 {
35958+
stroke-width: 2 !important;
35959+
}
35960+
3591335961
.lg\:table-auto {
3591435962
table-layout: auto !important;
3591535963
}
@@ -45592,6 +45640,18 @@ video {
4559245640
stroke: currentColor !important;
4559345641
}
4559445642

45643+
.xl\:stroke-0 {
45644+
stroke-width: 0 !important;
45645+
}
45646+
45647+
.xl\:stroke-1 {
45648+
stroke-width: 1 !important;
45649+
}
45650+
45651+
.xl\:stroke-2 {
45652+
stroke-width: 2 !important;
45653+
}
45654+
4559545655
.xl\:table-auto {
4559645656
table-layout: auto !important;
4559745657
}

__tests__/fixtures/tailwind-output.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6865,6 +6865,18 @@ video {
68656865
stroke: currentColor;
68666866
}
68676867

6868+
.stroke-0 {
6869+
stroke-width: 0;
6870+
}
6871+
6872+
.stroke-1 {
6873+
stroke-width: 1;
6874+
}
6875+
6876+
.stroke-2 {
6877+
stroke-width: 2;
6878+
}
6879+
68686880
.table-auto {
68696881
table-layout: auto;
68706882
}
@@ -16546,6 +16558,18 @@ video {
1654616558
stroke: currentColor;
1654716559
}
1654816560

16561+
.sm\:stroke-0 {
16562+
stroke-width: 0;
16563+
}
16564+
16565+
.sm\:stroke-1 {
16566+
stroke-width: 1;
16567+
}
16568+
16569+
.sm\:stroke-2 {
16570+
stroke-width: 2;
16571+
}
16572+
1654916573
.sm\:table-auto {
1655016574
table-layout: auto;
1655116575
}
@@ -26228,6 +26252,18 @@ video {
2622826252
stroke: currentColor;
2622926253
}
2623026254

26255+
.md\:stroke-0 {
26256+
stroke-width: 0;
26257+
}
26258+
26259+
.md\:stroke-1 {
26260+
stroke-width: 1;
26261+
}
26262+
26263+
.md\:stroke-2 {
26264+
stroke-width: 2;
26265+
}
26266+
2623126267
.md\:table-auto {
2623226268
table-layout: auto;
2623326269
}
@@ -35910,6 +35946,18 @@ video {
3591035946
stroke: currentColor;
3591135947
}
3591235948

35949+
.lg\:stroke-0 {
35950+
stroke-width: 0;
35951+
}
35952+
35953+
.lg\:stroke-1 {
35954+
stroke-width: 1;
35955+
}
35956+
35957+
.lg\:stroke-2 {
35958+
stroke-width: 2;
35959+
}
35960+
3591335961
.lg\:table-auto {
3591435962
table-layout: auto;
3591535963
}
@@ -45592,6 +45640,18 @@ video {
4559245640
stroke: currentColor;
4559345641
}
4559445642

45643+
.xl\:stroke-0 {
45644+
stroke-width: 0;
45645+
}
45646+
45647+
.xl\:stroke-1 {
45648+
stroke-width: 1;
45649+
}
45650+
45651+
.xl\:stroke-2 {
45652+
stroke-width: 2;
45653+
}
45654+
4559545655
.xl\:table-auto {
4559645656
table-layout: auto;
4559745657
}

__tests__/plugins/strokeWidth.test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import _ from 'lodash'
2+
import escapeClassName from '../../src/util/escapeClassName'
3+
import plugin from '../../src/plugins/strokeWidth'
4+
5+
test('the width of the stroke to be applied to the shape', () => {
6+
const addedUtilities = []
7+
8+
const config = {
9+
theme: {
10+
strokeWidth: {
11+
'0': '0',
12+
'1': '1px',
13+
'2': '2px',
14+
'3': '3px',
15+
'4': '4px',
16+
},
17+
},
18+
variants: {
19+
strokeWidth: ['responsive'],
20+
},
21+
}
22+
23+
const getConfigValue = (path, defaultValue) => _.get(config, path, defaultValue)
24+
const pluginApi = {
25+
config: getConfigValue,
26+
e: escapeClassName,
27+
theme: (path, defaultValue) => getConfigValue(`theme.${path}`, defaultValue),
28+
variants: (path, defaultValue) => {
29+
if (_.isArray(config.variants)) {
30+
return config.variants
31+
}
32+
33+
return getConfigValue(`variants.${path}`, defaultValue)
34+
},
35+
addUtilities(utilities, variants) {
36+
addedUtilities.push({
37+
utilities,
38+
variants,
39+
})
40+
},
41+
}
42+
43+
plugin()(pluginApi)
44+
45+
expect(addedUtilities).toEqual([
46+
{
47+
utilities: {
48+
'.stroke-w-0': { 'stroke-width': '0' },
49+
'.stroke-w-1': { 'stroke-width': '1px' },
50+
'.stroke-w-2': { 'stroke-width': '2px' },
51+
'.stroke-w-3': { 'stroke-width': '3px' },
52+
'.stroke-w-4': { 'stroke-width': '4px' },
53+
},
54+
variants: ['responsive'],
55+
},
56+
])
57+
})

src/corePlugins.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import resize from './plugins/resize'
5252
import boxShadow from './plugins/boxShadow'
5353
import fill from './plugins/fill'
5454
import stroke from './plugins/stroke'
55+
import strokeWidth from './plugins/strokeWidth'
5556
import tableLayout from './plugins/tableLayout'
5657
import textAlign from './plugins/textAlign'
5758
import textColor from './plugins/textColor'
@@ -144,6 +145,7 @@ export default function({ corePlugins: corePluginConfig }) {
144145
boxShadow,
145146
fill,
146147
stroke,
148+
strokeWidth,
147149
tableLayout,
148150
textAlign,
149151
textColor,

src/plugins/strokeWidth.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import _ from 'lodash'
2+
3+
export default function() {
4+
return function({ addUtilities, e, theme, variants }) {
5+
const utilities = _.fromPairs(
6+
_.map(theme('strokeWidth'), (value, modifier) => {
7+
return [
8+
`.${e(`stroke-${modifier}`)}`,
9+
{
10+
strokeWidth: value,
11+
},
12+
]
13+
})
14+
)
15+
16+
addUtilities(utilities, variants('strokeWidth'))
17+
}
18+
}

stubs/defaultConfig.stub.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ module.exports = {
368368
stroke: {
369369
current: 'currentColor',
370370
},
371+
strokeWidth: {
372+
'0': '0',
373+
'1': '1',
374+
'2': '2',
375+
},
371376
textColor: theme => theme('colors'),
372377
width: theme => ({
373378
auto: 'auto',
@@ -577,6 +582,7 @@ module.exports = {
577582
position: ['responsive'],
578583
resize: ['responsive'],
579584
stroke: ['responsive'],
585+
strokeWidth: ['responsive'],
580586
tableLayout: ['responsive'],
581587
textAlign: ['responsive'],
582588
textColor: ['responsive', 'hover', 'focus'],

0 commit comments

Comments
 (0)