Answer the question
In order to leave comments, you need to log in
How to rewrite a function so that linter does not swear?
There is a function that generates style classes.
It combines the elements of two arrays and returns all possible combinations between them.
const breakpoints = ['xs', 'sm', 'md'];
const sizes = [96, 136, 160];
for (const breakpoint of breakpoints) {
for (const size of sizes) {
styles[`${breakpoint}${size}`] = {
[theme.breakpoints[breakpoint === 'xs' ? 'down' : 'up'](breakpoint)]: { width: size, height: size },
};
}
}
xs96: {
[theme.breakpoints.up('md')]: {
width: '136px',
height: '136px',
},
},
xs136: {
[theme.breakpoints.up('md')]: {
width: '136px',
height: '136px',
},
},
xs160: {
[theme.breakpoints.up('md')]: {
width: '160px',
height: '160px',
},
},
...
...
const breakpoints = ['xs', 'sm', 'md'];
const sizes = [96, 136, 160];
const useStyles = makeStyles(theme => {
const styles = {
container: {
boxShadow: '0px 4px 8px rgba(60, 85, 165, 0.16)',
borderRadius: '8px',
overflow: 'hidden',
},
};
for (const breakpoint of breakpoints) {
for (const size of sizes) {
styles[`${breakpoint}${size}`] = {
[theme.breakpoints[breakpoint === 'xs' ? 'down' : 'up'](breakpoint)]: { width: size, height: size },
};
}
}
return styles;
});
const OrgLogo = ({ src, alt, xs = 96, sm = xs, md = sm }) => {
const classes = useStyles();
return (
<div className={clsx(classes.container, classes[`xs${xs}`], classes[`sm${sm}`], classes[`md${md}`])}>
<SquareImage src={src} alt={alt} />
</div>
);
};
Answer the question
In order to leave comments, you need to log in
use obj.forEach or .map
const frontMenu = (...arrayOfLabel) => Telegraf.Extra.markdown().markup((m) => m.inlineKeyboard(
arrayOfLabel.map((a) => a.map((b) => m.callbackButton(b.name, b.callback))),
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question