tailwind.config.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 formKitTailwind = require('@formkit/themes/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. light: '#25262D99',
  64. },
  65. blue: {
  66. DEFAULT: '#23A2CD',
  67. dark: '#045972',
  68. highlight: '#23A2CD4D',
  69. },
  70. yellow: {
  71. DEFAULT: '#FFCE33',
  72. highlight: '#FFCE331A',
  73. },
  74. red: {
  75. DEFAULT: '#E54011',
  76. highlight: '#E540111A',
  77. },
  78. green: {
  79. DEFAULT: '#36AF6A',
  80. highlight: '#38AD691A',
  81. },
  82. pink: '#EA4D84',
  83. 'dark-blue': '#045972',
  84. orange: '#F39804',
  85. },
  86. extend: {},
  87. },
  88. plugins: [
  89. formsPlugin,
  90. lineClampPlugin,
  91. formKitTailwind,
  92. plugin(({ addVariant }) => {
  93. addVariant('formkit-populated', [
  94. '&[data-populated]',
  95. '[data-populated] &',
  96. '[data-populated]&',
  97. ])
  98. addVariant('formkit-required', [
  99. '&[data-required]',
  100. '[data-required] &',
  101. '[data-required]&',
  102. ])
  103. addVariant('formkit-is-checked', [
  104. '&[data-is-checked]',
  105. '[data-is-checked] &',
  106. '[data-is-checked]&',
  107. ])
  108. addVariant('formkit-variant-primary', [
  109. '[data-variant="primary"] &',
  110. '[data-variant="primary"]&',
  111. ])
  112. addVariant('formkit-variant-secondary', [
  113. '[data-variant="secondary"] &',
  114. '[data-variant="secondary"]&',
  115. ])
  116. }),
  117. ],
  118. safelist: [...safelist.values()],
  119. }