Skip to content

Commit 37f9349

Browse files
committed
split src and tests
1 parent 62b1d3e commit 37f9349

File tree

7 files changed

+48
-11
lines changed

7 files changed

+48
-11
lines changed

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @tailwindcss/container-queries
22

3-
A plugin that provides utilities for container queries.
4-
3+
A plugin for Tailwind CSS v3.2+ that provides utilities for container queries.
54

65
## Installation
76

@@ -28,7 +27,22 @@ module.exports = {
2827

2928
## Usage
3029

31-
TODO
30+
```html
31+
<!-- Container queries without a specific container name -->
32+
<div>
33+
<!-- Container query with a size of `lg` defined in your tailwind.config.js file -->
34+
<div class="@lg:underline"></div>
35+
<div class="@[(min-width:_1024px)]:underline"></div>
36+
<div class="@[1024px]:underline"></div>
37+
</div>
38+
39+
<!-- Container queries that apply for a defined container name -->
40+
<div class="container/sidebar">
41+
<div class="@lg/sidebar:underline"></div>
42+
<div class="@[(min-width:_1024px)]/sidebar:underline"></div>
43+
<div class="@[1024px]/sidebar:underline"></div>
44+
</div>
45+
```
3246

3347
## Configuration
3448

index.d.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare global {
2+
namespace jest {
3+
interface Matchers<R> {
4+
toMatchFormattedCss(expected: string): CustomMatcherResult
5+
}
6+
}
7+
}
8+
9+
declare module 'tailwindcss' {
10+
export interface Config {
11+
theme: {
12+
/** Container queries */
13+
containers: Record<string, string>
14+
}
15+
}
16+
}
17+
18+
export {}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@swc/cli": "^0.1.57",
4343
"@swc/core": "^1.3.7",
4444
"@swc/jest": "^0.2.23",
45+
"@types/jest": "^29.1.2",
4546
"jest": "^29.1.2",
4647
"postcss": "^8.4.17",
4748
"prettier": "^2.7.1",

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import plugin from 'tailwindcss/plugin'
22
import { normalize } from 'tailwindcss/lib/util/dataTypes'
33

44
export = plugin(function containerQueries({ matchVariant, theme }) {
5-
let values = theme('containers') ?? {}
5+
let values: Record<string, string> = theme('containers') ?? {}
66

77
function parseValue(value: string): {
88
raw: string

src/index.test.ts renamed to tests/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html, css, run } from '~/jest/run'
1+
import { html, css, run } from './run'
22

33
it('container queries', () => {
44
let config = {

jest/run.js renamed to tests/run.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import path from 'path'
22
import postcss from 'postcss'
3-
import tailwind from 'tailwindcss'
4-
import containerQueries from '~/src'
3+
import tailwind, { Config } from 'tailwindcss'
4+
import containerQueries from '../src'
55

66
export let css = String.raw
77
export let html = String.raw
88
export let javascript = String.raw
99

10-
export function run(input, config, plugin = tailwind) {
10+
export function run(input: string, config: Config, plugin = tailwind) {
1111
let { currentTestName } = expect.getState()
1212

1313
config.plugins ??= []

tsconfig.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
"esModuleInterop": true,
1111
"moduleResolution": "node",
1212
"stripInternal": true,
13-
"outDir": "dist"
13+
"outDir": "dist",
14+
"allowJs": true,
15+
"types": ["./index.d.ts"]
1416
},
1517
"include": [
16-
"src/**/*.ts"
18+
"src/index.ts",
19+
"tests/index.ts"
1720
],
1821
"exclude": [
19-
"src/**/*.test.ts"
22+
"./tests/index.test.ts"
2023
]
2124
}
25+

0 commit comments

Comments
 (0)