Skip to content

Commit

Permalink
feat(style): add contain plugin (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD authored Feb 7, 2024
2 parents ce4feac + b543dd1 commit 960cc55
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
26 changes: 26 additions & 0 deletions packages/style/lib/contain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Config } from 'tailwindcss';
import plugin from 'tailwindcss/plugin.js';

export const containTheme: Config['theme'] = {
contain: {
none: 'none',
strict: 'strict',
size: 'size',
inlineSize: 'inline-size',
layout: 'layout',
style: 'style',
paint: 'paint',
content: 'content',
},
};

export const containPlugin = plugin(({matchUtilities, theme}) => {
matchUtilities(
{
contain: (value) => ({
contain: value,
}),
},
{ values: theme('contain') },
);
});
14 changes: 11 additions & 3 deletions packages/style/tailwind.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// import {join, dirname} from 'node:path';

import {animationTheme} from './lib/animation.js';
import {colorTheme, colorPlugin} from './lib/color-scheme.js';
import {containPlugin, containTheme} from './lib/contain.js';
import {directionPlugin} from './lib/direction.js';
import {elevationPlugin} from './lib/elevation.js';
import {safeAreaPlugin} from './lib/safe-area.js';
Expand All @@ -22,7 +21,16 @@ export const tailwindConfig: Omit<Config, 'content'> = {
...zIndexTheme,
...screenTheme,
...animationTheme,
...containTheme,
},
},
plugins: [colorPlugin, elevationPlugin, stateLayerPlugin, translucentPlugin, safeAreaPlugin, directionPlugin],
plugins: [
colorPlugin,
elevationPlugin,
stateLayerPlugin,
translucentPlugin,
safeAreaPlugin,
directionPlugin,
containPlugin,
],
};

0 comments on commit 960cc55

Please sign in to comment.