Skip to content

Commit

Permalink
[ONL-7628] fix tw grid plugin (#1578)
Browse files Browse the repository at this point in the history
* [ONL-7221] fix: Fixed TW classes generated by flexboxGridPlugin.

* increased version

---------

Co-authored-by: Milos Cibulka <mcibique@users.noreply.github.com>
  • Loading branch information
corinaper and mcibique committed Jun 23, 2023
1 parent 9becead commit d4ced94
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ebury/chameleon-components",
"version": "2.2.30",
"version": "2.2.31",
"main": "src/main.js",
"sideEffects": false,
"author": "Ebury Team (http://labs.ebury.rocks/)",
Expand Down
75 changes: 45 additions & 30 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,12 +1266,11 @@ function flexboxGridPlugin({ addUtilities, theme }) {
throw new Error('Number of columns must be a positive number');
}

const colClasses = [];
for (let i = 1; i <= numberOfColumns; i++) {
colClasses.push(`.col-${i}`);
}
const config = {
variants: ['responsive'],
};

const grid = {
addUtilities({
'.grid-container': {
width: '100%',
paddingRight: theme(`padding.${gutter / 2}`),
Expand All @@ -1283,37 +1282,53 @@ function flexboxGridPlugin({ addUtilities, theme }) {
marginRight: theme(`margin.${gutter / -2}`),
marginLeft: theme(`margin.${gutter / -2}`),
},
[`.col-full, .col, .col-auto, ${colClasses.join(', ')}`]: {
width: '100%',
padding: theme(`padding.${gutter / 2}`),
minHeight: theme('minHeight.1'),
},
[`.col, ${colClasses.join(', ')}`]: {
maxWidth: '100%',
flexGrow: 1,
flexBasis: 0,
},
};
}, config);

const colClasses = [];
for (let i = 1; i <= numberOfColumns; i++) {
const percentage = theme(`width.${i}/${numberOfColumns}`);
grid[`.col-${i}`] = {
flex: `0 0 ${percentage}`,
maxWidth: `${percentage}`,
};
colClasses.push(`.col-${i}`);
}

grid[`.offset-${i}`] = {
marginLeft: `${percentage}`,
};
for (const colClass of ['.col-full', '.col', '.col-auto', ...colClasses]) {
addUtilities({
[colClass]: {
width: '100%',
padding: theme(`padding.${gutter / 2}`),
minHeight: theme('minHeight.1'),
},
}, config);
}

grid['.col-auto'] = {
flex: '0 0 auto',
maxWidth: 'none',
width: 'auto',
};
for (const colClass of ['.col', ...colClasses]) {
addUtilities({
[colClass]: {
maxWidth: '100%',
flexGrow: 1,
flexBasis: 0,
},
}, config);
}

for (let i = 1; i <= numberOfColumns; i++) {
const percentage = theme(`width.${i}/${numberOfColumns}`);
addUtilities({
[`.col-${i}`]: {
flex: `0 0 ${percentage}`,
maxWidth: `${percentage}`,
},
[`.offset-${i}`]: {
marginLeft: `${percentage}`,
},
}, config);
}

addUtilities(grid, ['responsive']);
addUtilities({
'.col-auto': {
flex: '0 0 auto',
maxWidth: 'none',
width: 'auto',
},
}, config);
}

function stopColorPlugin({ matchUtilities, theme }) {
Expand Down

1 comment on commit d4ced94

@vercel
Copy link

@vercel vercel bot commented on d4ced94 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chameleon – ./

chameleon-dead-plane.vercel.app
chameleon-ebury.vercel.app
chameleon-git-master-ebury.vercel.app

Please sign in to comment.