Tailwindcss nextjs JIT mode compile error - css

We are making a project with tailwindcss and it was going good until the clients wanted a "pixel perfect" design which meant that we needed to set every single thing in pixels instead of rem. So instead of adding 1 gajillon classes like h-1px, h-2px ... h-100px, etc. I desided to enable JIT mode and use h-[100px] instead.
The problem is that the compiler keeps compiling, even tough i've changed nothing, and continues to do so, even when i stop the dev server, a process is running on port 3000 (i cannot start the server again, until i stop it).
So.. the question is how to stop this infinite loop of recompialtion
im using:
tailwindcss 2.1.2
tailwindcss/jit 0.1.18
my tw config is this for now, there might be something that is triggering the loop:
const colors = require("tailwindcss/colors");
const defaultTheme = require("tailwindcss/defaultTheme");
module.exports = {
important: true,
mode: "jit",
//content: ["./src/**/*.{js,ts,jsx,tsx,liquid}"],
purge: {
enabled: false,
content: [
"./src/components/**/*.{js,ts,jsx,tsx,html}",
"./src/pages/**/*.{js,ts,jsx,tsx,html}",
"./src/components/*.{js,ts,jsx,tsx,html}",
"./src/pages/*.{js,ts,jsx,tsx,html}",
"./src/**/*.{js,ts,jsx,tsx,html}",
"./src/*.{js,ts,jsx,tsx,html}",
"./**/*.{js,ts,jsx,tsx,html}",
"./*.{js,ts,jsx,tsx,html}",
],
options: {
safelist: {
deep: [/bg$/, /col$/, /row$/, /text$/],
greedy: [/bg$/, /col$/, /row$/, /text$/],
},
},
},
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
opacity: { 13: "0.13" },
boxShadow: {
head: "0 0 6px 0 rgba(0, 0, 0, 0.36)",
search: "0 9px 34px 0 rgba(0, 0, 0, 0.19)",
},
gridTemplateRows: {
// Simple 8 row grid
"8-em": "repeat(8, minmax(0, 5em))",
8: "repeat(8, minmax(0, 1fr))",
},
backgroundImage: {
"gradient-radial": "radial-gradient(var(--gradient-color-stops))",
},
fontFamily: {
sans: ["Stolzl", ...defaultTheme.fontFamily.sans],
},
fontSize: {
"2.5xl": "1.6rem",
0.8: "0.8rem",
xxs: "0.6rem",
micro: "0.4rem",
nano: "0.2rem",
},
zIndex: {
0: 0,
10: 10,
20: 20,
30: 30,
40: 40,
50: 50,
25: 25,
50: 50,
60: 60,
75: 75,
100: 100,
200: 200,
auto: "auto",
},
colors: {
// old primary blue #005a94
// old lightblue #f4f7fd
//TODO change colors
primaryLightBlue: "#f1f7fb",
primaryBlue: process.env.NEXT_PUBLIC_PRIMARY || "#1579B9",
primaryYellow: process.env.NEXT_PUBLIC_ACCENT || "#FDC607",
},
radialGradientColors: {
// defaults to {}
"blue-blue": ["#0171BA", "#005a94"],
"lb-lb": ["#3776dd", "#215dc0"],
},
animation: {
spin3d: "spin3d 6s linear infinite ",
},
keyframes: {
spin3d: {
"0%": {
transform: "perspective(1000px) rotateY(0deg)",
filter: "brightness(100%)",
},
"25%": { filter: "brightness(60%)" },
"50%": {
filter: "brightness(100%)",
},
"75%": { filter: "brightness(60%)" },
"100% ": {
transform: "perspective(1000px) rotateY(360deg)",
filter: "brightness(100%)",
},
},
},
},
},
plugins: [
require("tailwindcss-gradients"),
require("#tailwindcss/line-clamp"),
function ({ addComponents }) {
addComponents({
".container": {
maxWidth: "100%",
//640
"#screen sm": {
maxWidth: "640px",
},
//768
"#screen md": {
maxWidth: "768px",
},
//1024
"#screen lg": {
maxWidth: "1024px",
},
//1280
"#screen xl": {
maxWidth: "1280px",
},
//1280
"#screen 2xl": {
maxWidth: "1280px",
},
},
".container2": {
maxWidth: "100%",
//640
"#screen sm": {
maxWidth: "640px",
},
//768
"#screen md": {
maxWidth: "640px",
},
//1024
"#screen lg": {
maxWidth: "768px",
},
//1280
"#screen xl": {
maxWidth: "1118px",
},
//1280
"#screen 2xl": {
maxWidth: "1118px",
},
},
});
},
],
variants: {
display: ["group-hover"],
extend: {
backgroundColor: ["odd"],
borderColor: ["odd", "even", "active"],
borderOpacity: ["odd", "even", "active"],
borderWidth: ["odd", "even", "active"],
borderStyle: ["odd", "even", "active"],
display: ["disabled", "responsive"],
opacity: ["disabled"],
cursor: ["disabled", "hover"],
backgroundColor: ["disabled"],
borderWidth: ["hover,focus"],
transform: ["hover", "focus", "group-hover"],
scale: ["hover", "focus", "group-hover"],
width: ["hover", "group-hover"],
height: ["hover", "group-hover"],
padding: ["hover", "focus"],
},
},
};

I solved it, for anyone who has the same problem
first i had to uninstall #tailwindcss/jit dependency, as it is included in tailwind css v2.2.7+
then i had to configure postcss to use 'tailwindcss' instead of '#tailwindcss/jit',
then i changed my script to include TAILWIND_MODE=watch before my tailwind build script, and added --watch to the end
"tailwind:build": "TAILWIND_MODE=watch tailwind build -i ./src/styles/tailwind.css -o ./src/styles/styles.css --watch ",
and everything started working, no infinite loops!

Related

React Chart 2 only draw chart with gray background on production build

I am trying to create line chart with react-chart-2 and NextJs, and it seems to work fine on development.
But when I build project, I only got line chart with gray background. It very bad, how can I fix it. Thanks
What I want to get:
What I want to get
But what I really get:
What I really get
My code:
config = {
data: {
datasets: [
{
data: data ? data : [],
borderColor: '#ff0000',
borderWidth: 1,
radius: 0,
},
],
},
// text color "#fff"
Text: {
style: {
color: '#fff',
},
},
options: {
animation: false,
interaction: {
intersect: false,
},
plugins: {
legend: false,
},
scales: {
x: {
type: 'linear',
grid: {
display: false,
// borderColor: '#fff',
},
ticks: {
display: false,
},
},
y: {
grid: {
display: false,
borderColor: '#fff',
},
ticks: {
display: false,
},
},
},
},
},
My component:
<Line
options={config.options as any}
data={config.data as any}
/>

Tailwind space-x-# does not apply any styles

I have the following:
<div class="flex flex-row items-center justify-start flex-nowrap space-x-6">
<div>hello</div>
<div>world</div>
</div>
Now the there is no space-x-6 applied between the items. However when I try this in the Tailwind playground it works. Any ideas?
tailwind.config.js:
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {
animation: {
blob: 'blob 7s infinite',
},
keyframes: {
blob: {
'0%': {
transform: 'translate(0px, 0px) scale(1)',
},
'33%': {
transform: 'translate(30px, -50px) scale(1.1)',
},
'66%': {
transform: 'translate(-20px, 20px) scale(0.9)',
},
'100%': {
transform: 'tranlate(0px, 0px) scale(1)',
},
},
},
fontFamily: {
sans: ['Inter', ...defaultTheme.fontFamily.sans],
mono: ['iAWriter Mono', ...defaultTheme.fontFamily.mono],
},
boxShadow: {
card: '0 0 0.5rem rgba(0, 0, 0, 0.075)',
},
typography: (theme) => ({
DEFAULT: {
css: {
whiteSpace: 'pre-wrap',
figcaption: {
textAlign: 'center',
},
strong: {
fontWeight: theme('fontWeight.medium'),
},
// Image margin is handled by `figure`
img: {
marginTop: null,
marginBottom: null,
borderRadius: theme('borderRadius.lg'),
},
blockquote: {
borderLeftWidth: '2px',
fontStyle: null,
fontWeight: theme('fontWeight.normal'),
borderColor: theme('colors.blue.600'),
},
hr: {
borderTopWidth: '2px',
maxWidth: '12rem',
marginLeft: 'auto',
marginRight: 'auto',
},
'blockquote p:first-of-type::before, blockquote p:last-of-type::after': {
content: 'unset !important',
},
a: {
color: theme('colors.blue.600'),
wordWrap: 'break-word',
fontWeight: theme('fontWeight.normal'),
textDecoration: 'none',
textUnderlineOffset: '0.2em',
'&:hover': {
textDecoration: 'underline',
},
},
'ol > li::before': {
fontFamily: theme('fontFamily.mono').join(', '),
color: theme('colors.gray.400'),
},
'ul > li::before': {
backgroundColor: theme('colors.gray.400'),
},
'.twitter-tweet': {
marginLeft: 'auto',
marginRight: 'auto',
},
code: {
fontWeight: theme('fontWeight.normal'),
background: theme('colors.gray.200'),
color: theme('colors.gray.600'),
borderRadius: theme('borderRadius.lg'),
padding: `0.125rem ${theme('padding.1')}`,
'&::before, &::after': {
content: 'unset !important',
},
},
'[data-nft] *, .opengraph *, .opengraph *:hover': {
margin: '0',
textDecoration: 'none',
borderRadius: 'unset',
},
},
},
lg: {
css: {
'ol > li, ul > li': {
marginTop: '0',
marginBottom: '0',
},
// Image margin is handled by `figure`
img: {
marginTop: null,
marginBottom: null,
},
},
},
}),
},
},
plugins: [require('#tailwindcss/typography'), require('#tailwindcss/line-clamp'), require('#tailwindcss/forms')],
};
UPDATE:
So for the space-x-# class I do a little fancyness:
export function getSpacing(spacing, direction) {
const spacingTailwindClasses = [];
if (typeof direction === 'string') {
spacingTailwindClasses.push(getTailwindSpacingClassname(spacing, direction));
} else {
spacingTailwindClasses.push(getTailwindSpacingClassname(spacing, direction.sOnly || direction.sUp));
if (direction.sUp) {
spacingTailwindClasses.push(`sm:${getTailwindSpacingClassname(spacing, direction.sUp)}`);
if (direction.sOnly) {
spacingTailwindClasses.push(`sm:${getTailwindSpacingClassname('none', direction.sOnly)}`);
}
}
}
const spacingObject = {};
const classes = spacingTailwindClasses.join(' ');
spacingObject[classes] = true;
return spacingObject;
}

Override TextField Material 5.0

I've moved to MUI 5.0 and I'm having some issues with the migration. One problem is that I can no longer change the TextField globally and locally, if it is focused (e.g borderColor: 'blue',). The Textfield component is a bit more complicated and consists of multiple input Components.
It would be nice if somebody could help me with both cases
p.s thats the documentation https://mui.com/api/outlined-input/
globally
export const TextField = {
MuiOutlinedInput: {
styleOverrides: {
root: {
borderRadius: '1.5rem',
},
notchedOutline: {
borderColor: 'transparent',
'&.Mui-focused > fieldset': {
borderColor: 'blue',
},
},
input: {
color: palette.text.primary,
},
},
},
}
local (in the component itself not globally)
const styles = {
MuiOutlinedInput: {
root: {
borderRadius: '1.5rem',
},
notchedOutline: {
borderColor: 'transparent',
'&.Mui-focused > fieldset': {
borderColor: 'blue',
},
},
input: {
color: palette.text.primary,
},
},
}
<TextField sx={styles} />

React Material-UI Table how to set "border-spacing" for Table to have separated rows

I need separate Material-UI Collapsi Table Rows
https://material-ui.com/components/tables/#CollapsibleTable.tsx
const theme = createMuiTheme({
overrides: {
MuiTable: {
root: {
borderCollapse: "separate",
borderSpacing: "0 10px",
marginTop: "-10px"
}
},
MuiTableRow: {
root: {
borderRadius: 40,
border: "2px solid",
backgroundColor: "green",
},
},
},
});
To be something like this with spacing in between.
Best way is by setting the Theme, but Ill be glad for any advice.
It is useless to set borderRadius to MuiTableRow it is needed to use first-child last-child and MuiTableCell.
MuiTableCell: {
root: {
backgroundColor: "#fff",
paddingTop: 0,
paddingBottom: 0,
paddingLeft: "0.2rem",
paddingRight: "0.2rem",
borderBottom: 0,
overflow: "hidden",
textOverflow: "ellipsis",
"&:first-child": {
borderTopLeftRadius: "0.7rem",
borderBottomLeftRadius: "0.7rem"
},
"&:last-child": {
borderTopRightRadius: "0.7rem",
borderBottomRightRadius: "0.7rem"
}
}
},

Override of Button component doesn't change the hover color

I am trying to change the color of the all the Button's in the project by overriding the theme css. The color of the button has changed but hover color is still transparent, how can I override it ?
Is there any other way to this apart from adding a class to each of my buttons.
Also shouldn't all the variants of a button follow the css of the root?
const theme = createMuiTheme({
palette: {
primary: {
light: '#35C37D',
main: '#35C37D',
dark: '#35C37D',
// contrastText: will be calculated to contrast with palette.primary.main
},
secondary: {
light: '#35C37D',
main: '#35C37D',
// dark: will be calculated from palette.secondary.main,
contrastText: '#35C37D',
},
// error: will use the default color
},
overrides: {
MuiButton: {
// Name of the rule
root: {
// Some CSS
background: 'rgba(53, 195, 125, 100)',
borderRadius: 0,
border: 0,
colorInherit: '#fff',
color: 'white',
height: 40,
padding: '0 30px',
boxShadow: '4px 9px 26px 0 rgba(16,124,71,0.10)',
'&:hover': {
textDecoration: 'none',
backgroundColor: '#35C37D',
// Reset on touch devices, it doesn't add specificity
'#media (hover: none)': {
backgroundColor: '#35C37D',
},
},
},
textPrimary: {
color: '#fff',
},
textSecondary: {
color: '#fff',
},
contained: {
color: '#fff',
},
containedPrimary: {
color: '#fff',
},
containedSecondary: {
color: '#fff',
},
raised: {
color: '#fff',
},
colorInherit: {
color: '#fff',
},
},
},
typography: {
fontFamily: 'azo-sans-web',
// The default font size of the Material Specification.
fontSize: 14, // px
fontWeightLight: 300,
fontWeightRegular: 400,
fontWeightMedium: 500,
// Tell Material-UI what's the font-size on the html element.
// 16px is the default font-size used by browsers.
htmlFontSize: 16,
},
});
I figured it out.
Here is the code sandbox if anyone cares https://codesandbox.io/s/y2qyk9rn4x
Just need to add this for each variant:
outlined: {
"&:hover": {
backgroundColor: "#35C37D"
}
},

Resources