diff --git a/packages/material-tailwind-html/utils/withMT.js b/packages/material-tailwind-html/utils/withMT.js index 7dde5701a..d7b7248cc 100644 --- a/packages/material-tailwind-html/utils/withMT.js +++ b/packages/material-tailwind-html/utils/withMT.js @@ -14,7 +14,7 @@ const { alert } = require("../theme/components/alert"); const materialTailwindConfig = { darkMode: "class", - content: [], + content: ["hello"], theme: { colors, fontFamily: typography, @@ -28,37 +28,23 @@ const materialTailwindConfig = { ] }; -function arrayMerge(destinationArray, sourceArray) { - return destinationArray.concat(sourceArray).reduce((acc, cur) => { - if (acc.includes(cur)) return acc; - return [...acc, cur]; - }, []); -} - /** * Merge @material-tailwind and Tailwind CSS configurations * @param {object} tailwindConfig - Tailwind config object * @return {object} new config object */ function withTM(tailwindConfig) { - let purge; - if (Array.isArray(tailwindConfig.purge)) { - purge = { - content: tailwindConfig.purge - }; - } else { - purge = tailwindConfig.purge; - } + const themeFont = materialTailwindConfig.theme.fontFamily; - console.log(materialTailwindConfig); + if (tailwindConfig.theme.fontFamily) { + const { sans, serif, body } = tailwindConfig.theme.fontFamily; + + themeFont.sans = sans || themeFont.sans; + themeFont.serif = serif || themeFont.serif; + themeFont.body = body || themeFont.body; + } - return merge( - materialTailwindConfig, - { ...tailwindConfig, purge }, - { - arrayMerge - } - ); + return merge(materialTailwindConfig, { ...tailwindConfig }); } module.exports = withTM; diff --git a/packages/material-tailwind-react/src/utils/withMT.js b/packages/material-tailwind-react/src/utils/withMT.js index 9af35e48c..432498ab6 100644 --- a/packages/material-tailwind-react/src/utils/withMT.js +++ b/packages/material-tailwind-react/src/utils/withMT.js @@ -21,35 +21,23 @@ const materialTailwindConfig = { plugins: [], }; -function arrayMerge(destinationArray, sourceArray) { - return destinationArray.concat(sourceArray).reduce((acc, cur) => { - if (acc.includes(cur)) return acc; - return [...acc, cur]; - }, []); -} - /** * Merge @material-tailwind and Tailwind CSS configurations * @param {object} tailwindConfig - Tailwind config object * @return {object} new config object */ function withTM(tailwindConfig) { - let purge; - if (Array.isArray(tailwindConfig.purge)) { - purge = { - content: tailwindConfig.purge, - }; - } else { - purge = tailwindConfig.purge; + const themeFont = materialTailwindConfig.theme.fontFamily; + + if (tailwindConfig.theme.fontFamily) { + const { sans, serif, body } = tailwindConfig.theme.fontFamily; + + themeFont.sans = sans || themeFont.sans; + themeFont.serif = serif || themeFont.serif; + themeFont.body = body || themeFont.body; } - return merge( - materialTailwindConfig, - { ...tailwindConfig, purge }, - { - arrayMerge, - }, - ); + return merge(materialTailwindConfig, { ...tailwindConfig }); } module.exports = withTM; diff --git a/pages/index.js b/pages/index.js index ae81e6811..cb91870f1 100644 --- a/pages/index.js +++ b/pages/index.js @@ -226,7 +226,7 @@ export default function Home() { -