-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtailwind.config.cjs
146 lines (137 loc) · 3.78 KB
/
tailwind.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* eslint-disable */
const fs = require('node:fs')
const path = require('node:path')
const postcss = require('postcss')
const plugin = require('tailwindcss/plugin')
const pxToRem = (px, defaultFontSize = 16) => {
return `${px / defaultFontSize}rem`
}
/**
* Loads CSS files through Tailwind’s plugin system to enable IntelliSense support.
*
* This plugin scans CSS files from `src/styles/{base,components,utilities}` and appends them to
* their respective layers.
*/
const cssFiles = plugin(({ addBase, addComponents, addUtilities }) => {
const layers = ['base', 'components', 'utilities']
const stylesDir = path.join(__dirname, 'src/styles')
const addStylesMap = {
base: addBase,
components: addComponents,
utilities: addUtilities,
}
for (const layer of layers) {
const layerDir = path.join(stylesDir, layer)
const files = fs.readdirSync(layerDir)
const addStyles = addStylesMap[layer]
for (const file of files) {
if (path.extname(file) === '.css') {
const filePath = path.join(layerDir, file)
const content = fs.readFileSync(filePath, 'utf8')
const styles = postcss.parse(content)
addStyles(styles.nodes)
}
}
}
})
/**
* Create a responsive grid layout without media queries using CSS Grid.
*
* This plugin is based on a method provided by Andy Bell on piccalil.li.
* See: https://piccalil.li/tutorial/create-a-responsive-grid-layout-with-no-media-queries-using-css-grid/
*/
const autoGrid = plugin(
({ addComponents, matchComponents, theme }) => {
const values = theme('autoGrid')
matchComponents(
{
'auto-grid': (value) => ({
display: 'grid',
'grid-template-columns': `repeat(auto-fill, minmax(min(${value}, 100%), 1fr))`,
}),
},
{ values },
)
addComponents({
'.auto-grid-none': {
display: 'revert',
'grid-template-columns': 'revert',
},
})
},
{
theme: {
autoGrid: ({ theme }) => ({
...theme('spacing'),
}),
},
},
)
// バリアブルフォントのwidthを指定するためのクラス追加
const fontWidth = plugin(({ matchUtilities, theme }) => {
matchUtilities(
{
'text-w': (value) => ({
'font-variation-settings': `'wdth' ${value}`,
}),
},
{
values: theme('fontWidth'),
},
)
})
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
future: {
hoverOnlyWhenSupported: true,
},
theme: {
screens: {
sm: '350px',
md: '768px',
lg: '1024px',
xl: '1280px',
'2xl': '1440px',
},
spacing: Object.fromEntries(Array.from({ length: 301 }, (_, i) => [`${i}`, pxToRem(i)])),
fontSize: Object.fromEntries(Array.from({ length: 50 }, (_, i) => [`${i}`, pxToRem(i)])),
fontWidth: {
regular: 100,
90: 90,
94: 94,
95: 95,
109: 109,
},
extend: {
fontFamily: {
shiftbrain: ['SHIFTBRAIN Norms Variable, sans-serif'],
noto: ['Noto Sans JP', 'SHIFTBRAIN Norms Variable', 'sans-serif'],
'shiftbrain-noto': ['SHIFTBRAIN Norms Variable', 'Noto Sans JP', 'sans-serif'],
},
colors: {
transparent: 'transparent',
white: {
DEFAULT: '#ffffff',
primary: '#F5F5F5',
},
black: {
DEFAULT: '#000000',
primary: '#1C1C1C',
},
gray: {
200: '#EDEDED',
300: '#E0E0E0',
500: '#CCCCCC',
600: '#6C6C6C',
700: '#5F5F5F',
900: '#303030',
},
},
transitionTimingFunction: {
out1: 'cubic-bezier(0.25, 1, 0.5, 1)',
},
},
},
plugins: [require('@tailwindcss/container-queries'), cssFiles, autoGrid, fontWidth],
}