tailwind.config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. const colors = require('tailwindcss/colors')
  3. const formsPlugin = require('@tailwindcss/forms')
  4. const lineClampPlugin = require('@tailwindcss/line-clamp')
  5. const formKitPlugin = require('@formkit/tailwindcss')
  6. const plugin = require('tailwindcss/plugin')
  7. const path = require('path')
  8. const fs = require('fs')
  9. // TODO: Move utility code elsewhere?
  10. function* walkSync(dir) {
  11. const files = fs.readdirSync(dir, { withFileTypes: true })
  12. for (const file of files) {
  13. if (file.isDirectory()) {
  14. yield* walkSync(path.join(dir, file.name))
  15. } else {
  16. yield path.join(dir, file.name)
  17. }
  18. }
  19. }
  20. // Here we need to add classes which are only present in the FormSchema back end, as Tailwind
  21. // can't detect them otherwise.
  22. const safelist = new Set()
  23. for (const filePath of walkSync(`${__dirname}/app/models/form_schema/form/`)) {
  24. const content = fs.readFileSync(filePath).toString()
  25. for (const match of content.matchAll(/class: '([^']+)'/g)) {
  26. for (const klass of match[1].split(/[ ]+/)) {
  27. safelist.add(klass)
  28. }
  29. }
  30. }
  31. // Add the moment we can use one tailwind config for the mobile app, but later we need to check
  32. // how this works with different apps.
  33. module.exports = {
  34. content: [`${path.resolve(__dirname)}/app/frontend/**/*.{js,jsx,ts,tsx,vue}`],
  35. theme: {
  36. fontFamily: {
  37. sans: [
  38. '"Fira Sans"',
  39. '"Helvetica Neue"',
  40. 'Helvetica',
  41. 'Arial',
  42. 'sans-serif',
  43. ],
  44. },
  45. colors: {
  46. transparent: 'transparent',
  47. current: 'currentColor',
  48. black: {
  49. DEFAULT: '#191919',
  50. full: colors.black,
  51. },
  52. white: colors.white,
  53. gray: {
  54. DEFAULT: '#999999',
  55. 100: '#D1D1D1',
  56. 150: '#D8D8D8',
  57. 200: '#656567',
  58. 300: '#4C4C4D',
  59. 400: '#323234',
  60. 500: '#282829',
  61. 600: '#262627',
  62. highlight: '#99999926',
  63. },
  64. blue: {
  65. DEFAULT: '#23A2CD',
  66. dark: '#045972',
  67. highlight: '#23A2CD4D',
  68. },
  69. yellow: {
  70. DEFAULT: '#FFCE33',
  71. highlight: '#FFCE331A',
  72. },
  73. red: {
  74. DEFAULT: '#E54011',
  75. highlight: '#E540111A',
  76. },
  77. green: {
  78. DEFAULT: '#36AF6A',
  79. highlight: '#38AD691A',
  80. },
  81. pink: '#EA4D84',
  82. 'dark-blue': '#045972',
  83. orange: '#F39804',
  84. },
  85. extend: {},
  86. },
  87. plugins: [
  88. formsPlugin,
  89. lineClampPlugin,
  90. formKitPlugin.default,
  91. plugin(({ addVariant }) => {
  92. addVariant('formkit-populated', [
  93. '&[data-populated]',
  94. '[data-populated] &',
  95. '[data-populated]&',
  96. ])
  97. addVariant('formkit-is-checked', [
  98. '&[data-is-checked]',
  99. '[data-is-checked] &',
  100. '[data-is-checked]&',
  101. ])
  102. }),
  103. ],
  104. safelist: [...safelist.values()],
  105. }