tailwind.config.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /** @type {import('tailwindcss').Config} */
  2. // const lineClamp = require("@tailwindcss/line-clamp");
  3. // module.exports = {
  4. // content: [
  5. // "./pages/**/*.{js,ts,jsx,tsx}",
  6. // "./src/**/*.{js,ts,jsx,tsx}",
  7. // "./components/**/*.{js,ts,jsx,tsx}",
  8. // ],
  9. // darkMode: "class",
  10. // theme: {
  11. // extend: {
  12. // colors: {
  13. // default: "var(--color-bg-default)",
  14. // "default-alpha": "var(--color-bg-default-alpha)",
  15. // paper: "var(--color-paper)",
  16. // "paper-alpha": "var(--color-paper-alpha)",
  17. // primary: "var(--color-primary)",
  18. // secondary: "var(--color-secondary)",
  19. // error: "var(--color-error)",
  20. // warning: "var(--color-warning)",
  21. // info: "var(--color-info)",
  22. // success: "var(--color-success)",
  23. // "gray-light": "var(--color-gray-light)",
  24. // "gray-dark": "var(--color-gray-dark)",
  25. // },
  26. // fontFamily: {
  27. // sans: [
  28. // "Nunito Sans,SF Pro Text,SF Pro Icons,Roboto,Helvetica Neue,Helvetica,Arial,sans-serif",
  29. // ],
  30. // },
  31. // },
  32. // },
  33. // plugins: [lineClamp],
  34. // };
  35. const defaultTheme = require("tailwindcss/defaultTheme");
  36. // const svgToDataUri = require("mini-svg-data-uri");
  37. const {
  38. default: flattenColorPalette,
  39. } = require("tailwindcss/lib/util/flattenColorPalette");
  40. module.exports = {
  41. // experimental: {
  42. // optimizeUniversalDefaults: true,
  43. // },
  44. content: [
  45. "./pages/**/*.{js,ts,jsx,tsx}",
  46. "./src/**/*.{js,ts,jsx,tsx}",
  47. "./components/**/*.{js,ts,jsx,tsx}",
  48. ],
  49. darkMode: "class",
  50. theme: {
  51. // `demo-*` screens are used for the "mobile-first" responsive demo
  52. screens: {
  53. sm: "640px",
  54. "demo-sm": "720px",
  55. md: "768px",
  56. lg: "1024px",
  57. xl: "1280px",
  58. "2xl": "1536px",
  59. },
  60. aspectRatio: {
  61. auto: "auto",
  62. square: "1 / 1",
  63. video: "16 / 9",
  64. 1: "1",
  65. 2: "2",
  66. 3: "3",
  67. 4: "4",
  68. 5: "5",
  69. 6: "6",
  70. 7: "7",
  71. 8: "8",
  72. 9: "9",
  73. 10: "10",
  74. 11: "11",
  75. 12: "12",
  76. 13: "13",
  77. 14: "14",
  78. 15: "15",
  79. 16: "16",
  80. },
  81. extend: {
  82. typography: (theme) => ({
  83. DEFAULT: {
  84. css: {
  85. maxWidth: "none",
  86. color: theme("colors.slate.700"),
  87. hr: {
  88. borderColor: theme("colors.slate.100"),
  89. marginTop: "3em",
  90. marginBottom: "3em",
  91. },
  92. "h1, h2, h3": {
  93. letterSpacing: "-0.025em",
  94. },
  95. h2: {
  96. marginBottom: `${16 / 24}em`,
  97. },
  98. h3: {
  99. marginTop: "2.4em",
  100. lineHeight: "1.4",
  101. },
  102. h4: {
  103. marginTop: "2em",
  104. fontSize: "1.125em",
  105. },
  106. "h2 small, h3 small, h4 small": {
  107. fontFamily: theme("fontFamily.mono").join(", "),
  108. color: theme("colors.slate.500"),
  109. fontWeight: 500,
  110. },
  111. "h2 small": {
  112. fontSize: theme("fontSize.lg")[0],
  113. ...theme("fontSize.lg")[1],
  114. },
  115. "h3 small": {
  116. fontSize: theme("fontSize.base")[0],
  117. ...theme("fontSize.base")[1],
  118. },
  119. "h4 small": {
  120. fontSize: theme("fontSize.sm")[0],
  121. ...theme("fontSize.sm")[1],
  122. },
  123. "h2, h3, h4": {
  124. "scroll-margin-top": "var(--scroll-mt)",
  125. },
  126. ul: {
  127. listStyleType: "none",
  128. paddingLeft: 0,
  129. },
  130. "ul > li": {
  131. position: "relative",
  132. paddingLeft: "1.75em",
  133. },
  134. "ul > li::before": {
  135. content: '""',
  136. width: "0.75em",
  137. height: "0.125em",
  138. position: "absolute",
  139. top: "calc(0.875em - 0.0625em)",
  140. left: 0,
  141. borderRadius: "999px",
  142. backgroundColor: theme("colors.slate.300"),
  143. },
  144. a: {
  145. fontWeight: theme("fontWeight.semibold"),
  146. textDecoration: "none",
  147. borderBottom: `1px solid ${theme("colors.sky.300")}`,
  148. },
  149. "a:hover": {
  150. borderBottomWidth: "2px",
  151. },
  152. "a code": {
  153. color: "inherit",
  154. fontWeight: "inherit",
  155. },
  156. strong: {
  157. color: theme("colors.slate.900"),
  158. fontWeight: theme("fontWeight.semibold"),
  159. },
  160. "a strong": {
  161. color: "inherit",
  162. fontWeight: "inherit",
  163. },
  164. kbd: {
  165. background: theme("colors.slate.100"),
  166. borderWidth: "1px",
  167. borderColor: theme("colors.slate.200"),
  168. padding: "0.125em 0.25em",
  169. color: theme("colors.slate.700"),
  170. fontWeight: 500,
  171. fontSize: "0.875em",
  172. fontVariantLigatures: "none",
  173. borderRadius: "4px",
  174. margin: "0 1px",
  175. },
  176. code: {
  177. fontWeight: theme("fontWeight.medium"),
  178. fontVariantLigatures: "none",
  179. },
  180. pre: {
  181. color: theme("colors.slate.50"),
  182. borderRadius: theme("borderRadius.xl"),
  183. padding: theme("padding.5"),
  184. boxShadow: theme("boxShadow.md"),
  185. display: "flex",
  186. marginTop: `${20 / 14}em`,
  187. marginBottom: `${32 / 14}em`,
  188. },
  189. "p + pre": {
  190. marginTop: `${-4 / 14}em`,
  191. },
  192. "pre + pre": {
  193. marginTop: `${-16 / 14}em`,
  194. },
  195. "pre code": {
  196. flex: "none",
  197. minWidth: "100%",
  198. },
  199. table: {
  200. fontSize: theme("fontSize.sm")[0],
  201. lineHeight: theme("fontSize.sm")[1].lineHeight,
  202. },
  203. thead: {
  204. color: theme("colors.slate.700"),
  205. borderBottomColor: theme("colors.slate.200"),
  206. },
  207. "thead th": {
  208. paddingTop: 0,
  209. fontWeight: theme("fontWeight.semibold"),
  210. },
  211. "tbody tr": {
  212. borderBottomColor: theme("colors.slate.100"),
  213. },
  214. "tbody tr:last-child": {
  215. borderBottomWidth: "1px",
  216. },
  217. "tbody code": {
  218. fontSize: theme("fontSize.xs")[0],
  219. },
  220. "figure figcaption": {
  221. textAlign: "center",
  222. fontStyle: "italic",
  223. },
  224. "figure > figcaption": {
  225. marginTop: `${12 / 14}em`,
  226. },
  227. },
  228. },
  229. dark: {
  230. css: {
  231. color: theme("colors.slate.400"),
  232. "h2, h3, h4, thead th": {
  233. color: theme("colors.slate.200"),
  234. },
  235. "h2 small, h3 small, h4 small": {
  236. color: theme("colors.slate.400"),
  237. },
  238. kbd: {
  239. background: theme("colors.slate.700"),
  240. borderColor: theme("colors.slate.600"),
  241. color: theme("colors.slate.200"),
  242. },
  243. code: {
  244. color: theme("colors.slate.200"),
  245. },
  246. hr: {
  247. borderColor: theme("colors.slate.200"),
  248. opacity: "0.05",
  249. },
  250. pre: {
  251. boxShadow: "inset 0 0 0 1px rgb(255 255 255 / 0.1)",
  252. },
  253. a: {
  254. color: theme("colors.white"),
  255. borderBottomColor: theme("colors.sky.400"),
  256. },
  257. strong: {
  258. color: theme("colors.slate.200"),
  259. },
  260. thead: {
  261. color: theme("colors.slate.300"),
  262. borderBottomColor: "rgb(148 163 184 / 0.2)",
  263. },
  264. "tbody tr": {
  265. borderBottomColor: "rgb(148 163 184 / 0.1)",
  266. },
  267. blockQuote: {
  268. color: theme("colors.white"),
  269. },
  270. },
  271. },
  272. }),
  273. fontFamily: {
  274. sans: [
  275. "Nunito Sans",
  276. "SF Pro Text",
  277. "SF Pro Icons",
  278. "Inter var",
  279. ...defaultTheme.fontFamily.sans,
  280. ],
  281. serif: ["Merriweather", ...defaultTheme.fontFamily.serif],
  282. mono: ["Fira Code VF", ...defaultTheme.fontFamily.mono],
  283. source: ["Source Sans Pro", ...defaultTheme.fontFamily.sans],
  284. "ubuntu-mono": ["Ubuntu Mono", ...defaultTheme.fontFamily.mono],
  285. },
  286. spacing: {
  287. 18: "4.5rem",
  288. full: "100%",
  289. },
  290. maxWidth: {
  291. "8xl": "90rem",
  292. },
  293. keyframes: {
  294. "flash-code": {
  295. "0%": { backgroundColor: "rgb(125 211 252 / 0.1)" },
  296. "100%": { backgroundColor: "transparent" },
  297. },
  298. },
  299. animation: {
  300. "flash-code": "flash-code 1s forwards",
  301. "flash-code-slow": "flash-code 2s forwards",
  302. },
  303. // backgroundImage: (theme) => ({
  304. // squiggle: `url("${svgToDataUri(
  305. // `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 3" enable-background="new 0 0 6 3" width="6" height="3" fill="${theme(
  306. // "colors.yellow.400"
  307. // )}"><polygon points="5.5,0 2.5,3 1.1,3 4.1,0"/><polygon points="4,0 6,2 6,0.6 5.4,0"/><polygon points="0,2 1,3 2.4,3 0,0.6"/></svg>`
  308. // )}")`,
  309. // }),
  310. },
  311. },
  312. plugins: [
  313. // require("daisyui"),
  314. require("@tailwindcss/line-clamp"),
  315. require("@tailwindcss/typography"),
  316. require("@tailwindcss/aspect-ratio"),
  317. require("@tailwindcss/forms")({ strategy: "class" }),
  318. function ({ addVariant }) {
  319. addVariant(
  320. "supports-backdrop-blur",
  321. "@supports (backdrop-filter: blur(0)) or (-webkit-backdrop-filter: blur(0))"
  322. );
  323. addVariant(
  324. "supports-scrollbars",
  325. "@supports selector(::-webkit-scrollbar)"
  326. );
  327. addVariant("children", "& > *");
  328. addVariant("scrollbar", "&::-webkit-scrollbar");
  329. addVariant("scrollbar-track", "&::-webkit-scrollbar-track");
  330. addVariant("scrollbar-thumb", "&::-webkit-scrollbar-thumb");
  331. },
  332. function ({ matchUtilities, theme }) {
  333. // matchUtilities(
  334. // {
  335. // "bg-grid": (value) => ({
  336. // backgroundImage: `url("${svgToDataUri(
  337. // `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="${value}"><path d="M0 .5H31.5V32"/></svg>`
  338. // )}")`,
  339. // }),
  340. // },
  341. // { values: flattenColorPalette(theme("backgroundColor")), type: "color" }
  342. // );
  343. matchUtilities(
  344. {
  345. highlight: (value) => ({ boxShadow: `inset 0 1px 0 0 ${value}` }),
  346. },
  347. { values: flattenColorPalette(theme("backgroundColor")), type: "color" }
  348. );
  349. },
  350. function ({ addUtilities, theme }) {
  351. let backgroundSize = "7.07px 7.07px";
  352. let backgroundImage = (color) =>
  353. `linear-gradient(135deg, ${color} 10%, transparent 10%, transparent 50%, ${color} 50%, ${color} 60%, transparent 60%, transparent 100%)`;
  354. let colors = Object.entries(theme("backgroundColor")).filter(
  355. ([, value]) => typeof value === "object" && value[400] && value[500]
  356. );
  357. addUtilities(
  358. Object.fromEntries(
  359. colors.map(([name, colors]) => {
  360. let backgroundColor = colors[400] + "1a"; // 10% opacity
  361. let stripeColor = colors[500] + "80"; // 50% opacity
  362. return [
  363. `.bg-stripes-${name}`,
  364. {
  365. backgroundColor,
  366. backgroundImage: backgroundImage(stripeColor),
  367. backgroundSize,
  368. },
  369. ];
  370. })
  371. )
  372. );
  373. addUtilities({
  374. ".bg-stripes-white": {
  375. backgroundImage: backgroundImage("rgba(255 255 255 / 0.75)"),
  376. backgroundSize,
  377. },
  378. });
  379. addUtilities({
  380. ".ligatures-none": {
  381. fontVariantLigatures: "none",
  382. },
  383. });
  384. },
  385. ],
  386. };