Skip to content

Commit 6729524

Browse files
tmkxthecrypticace
andauthored
Support font-weight in font-size utilities (#8763)
* Support font-weight in font-size utilities * WIP update tests * Update changelog Co-authored-by: Jordan Pittman <[email protected]>
1 parent 1318cb6 commit 6729524

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Fix usage of special-character prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
1515
- Don’t prefix selectors in arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
1616
- Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
17+
- Support default `font-weight`s in font size utilities ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
1718

1819
## [3.1.4] - 2022-06-21
1920

src/corePlugins.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1613,14 +1613,15 @@ export let corePlugins = {
16131613
{
16141614
text: (value) => {
16151615
let [fontSize, options] = Array.isArray(value) ? value : [value]
1616-
let { lineHeight, letterSpacing } = isPlainObject(options)
1616+
let { lineHeight, letterSpacing, fontWeight } = isPlainObject(options)
16171617
? options
16181618
: { lineHeight: options }
16191619

16201620
return {
16211621
'font-size': fontSize,
16221622
...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
16231623
...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
1624+
...(fontWeight === undefined ? {} : { 'font-weight': fontWeight }),
16241625
}
16251626
},
16261627
},

tests/plugins/fontSize.test.js

+31
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,34 @@ test('font-size utilities can include a default line-height and letter-spacing',
8888
`)
8989
})
9090
})
91+
92+
test('font-size utilities can include a font-weight', () => {
93+
let config = {
94+
content: [{ raw: html`<div class="text-md text-sm text-lg"></div>` }],
95+
theme: {
96+
fontSize: {
97+
sm: '12px',
98+
md: ['16px', { lineHeight: '24px', fontWeight: 500 }],
99+
lg: ['20px', { lineHeight: '28px', fontWeight: 'bold' }],
100+
},
101+
},
102+
}
103+
104+
return run('@tailwind utilities', config).then((result) => {
105+
expect(result.css).toMatchCss(css`
106+
.text-md {
107+
font-size: 16px;
108+
line-height: 24px;
109+
font-weight: 500;
110+
}
111+
.text-sm {
112+
font-size: 12px;
113+
}
114+
.text-lg {
115+
font-size: 20px;
116+
line-height: 28px;
117+
font-weight: bold;
118+
}
119+
`)
120+
})
121+
})

types/config.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ interface ThemeConfig {
164164
configuration: Partial<{
165165
lineHeight: string
166166
letterSpacing: string
167+
fontWeight: string | number
167168
}>
168169
]
169170
>

0 commit comments

Comments
 (0)