Skip to content

Commit ba9d177

Browse files
authored
Rename completions and remove color information (tailwindlabs#5662)
1 parent 84db333 commit ba9d177

File tree

3 files changed

+23
-40
lines changed

3 files changed

+23
-40
lines changed

src/lib/setupContextUtils.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -631,27 +631,17 @@ function registerPlugins(plugins, context) {
631631
return output.map((value) => ({ raw: value, extension: 'html' }))
632632
}
633633

634-
// Generate a list of strings for autocompletion purposes. Colors will have a
635-
// tuple with options, e.g.:
636-
// ['uppercase', 'lowercase', ['bg-red', { color: 'rgb(255 0 0)' }]]
637-
context.completions = function () {
638-
// TODO: Try and detect color from components?
639-
// TODO: Should we provide a simple "public api" file with functions?
634+
// Generate a list of strings for autocompletion purposes, e.g.
635+
// ['uppercase', 'lowercase', ...]
636+
context.getClassList = function () {
640637
let output = []
641638

642639
for (let util of classList) {
643640
if (Array.isArray(util)) {
644641
let [utilName, options] = util
645-
let isColor = [].concat(options.type).includes('color')
646642

647-
if (isColor) {
648-
for (let [value, color] of Object.entries(options?.values ?? {})) {
649-
output.push([formatClass(utilName, value), { color }])
650-
}
651-
} else {
652-
for (let value of Object.keys(options?.values ?? {})) {
653-
output.push(formatClass(utilName, value))
654-
}
643+
for (let value of Object.keys(options?.values ?? {})) {
644+
output.push(formatClass(utilName, value))
655645
}
656646
} else {
657647
output.push(util)

tests/completions.test.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/getClassList.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import resolveConfig from '../src/public/resolve-config'
2+
import { createContext } from '../src/lib/setupContextUtils'
3+
4+
it('should generate every possible class, without variants', () => {
5+
let config = {}
6+
7+
let context = createContext(resolveConfig(config))
8+
expect(context.getClassList()).toBeInstanceOf(Array)
9+
10+
// Verify we have a `container` for the 'components' section.
11+
expect(context.getClassList()).toContain('container')
12+
13+
// Verify we handle the DEFAULT case correctly
14+
expect(context.getClassList()).toContain('border')
15+
16+
// Verify we handle negative values correctly
17+
expect(context.getClassList()).toContain('-inset-1/4')
18+
})

0 commit comments

Comments
 (0)