Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add windicss #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"vue-router": "^4.1.6"
},
"dependencies": {
"konsta": "file:src"
"konsta": "file:src",
"windicss": "^3.5.6"
}
}
}
4 changes: 3 additions & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"import": "./svelte/konsta-svelte.js"
},
"./config": "./config.js",
"./config.js": "./config.js"
"./config.js": "./config.js",
"./configWindicss": "./configWindicss.js",
"./configWindicss.js": "./configWindicss.js"
}
}
25 changes: 13 additions & 12 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const plugin = require('tailwindcss/plugin');
const configExtend = require('./config/config-extend.js');
const extendTheme = require('./config/extend-theme.js');

Expand Down Expand Up @@ -36,18 +37,18 @@ const config = (userConfig = {}) => {
extend: extendTheme(konstaConfig),
},
plugins: [
pluginBase(userConfig, konstaConfig),
pluginPreloader(),
pluginIosMaterial(),
pluginHairlines(),
pluginTouchRipple(),
pluginLineClamp(),
pluginSafeAreas(),
pluginTranslucent(),
pluginRange(),
pluginTouch(),
pluginNoScrollbar(),
pluginColors(konstaConfig),
pluginBase(plugin, userConfig, konstaConfig),
pluginPreloader(plugin),
pluginIosMaterial(plugin),
pluginHairlines(plugin),
pluginTouchRipple(plugin),
pluginLineClamp(plugin),
pluginSafeAreas(plugin),
pluginTranslucent(plugin),
pluginRange(plugin),
pluginTouch(plugin),
pluginNoScrollbar(plugin),
pluginColors(plugin, konstaConfig),
],
},
userConfigModified
Expand Down
3 changes: 1 addition & 2 deletions src/config/plugin-base.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const plugin = require('tailwindcss/plugin');
const hexToRgb = require('./hex-to-rgb.js');
const iosColors = require('./ios-colors.js');
const mdColors = require('./md-colors.js');

module.exports = (userConfig = {}, konstConfig = {}) => {
module.exports = (plugin, userConfig = {}, konstConfig = {}) => {
let iosFont =
'-apple-system, SF Pro Text, SF UI Text, system-ui, Helvetica Neue, Helvetica, Arial, sans-serif';
let materialFont = 'Roboto, system-ui, Noto, Helvetica, Arial, sans-serif';
Expand Down
3 changes: 1 addition & 2 deletions src/config/plugin-colors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const plugin = require('tailwindcss/plugin');
const hexToRgb = require('./hex-to-rgb.js');
const iosColors = require('./ios-colors.js');
const mdColors = require('./md-colors.js');
Expand All @@ -20,7 +19,7 @@ const rulesForColor = (name, hex) => {
};
};

module.exports = (konstaConfig) =>
module.exports = (plugin, konstaConfig) =>
plugin(({ addUtilities }) => {
const themeColors = konstaConfig.colors;

Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-hairlines.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities, theme }) => {
const themeColors = theme('colors');
const themeDurations = theme('transitionDuration');
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-ios-material.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addVariant, e }) => {
addVariant('material', ({ modifySelectors, separator }) => {
modifySelectors(({ className, selector }) => {
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-line-clamp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities }) => {
const lineClamp = {};
Array.from({ length: 10 }).forEach((_, index) => {
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-no-scrollbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities }) => {
const noScrollbar = {
'.no-scrollbar': {
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-preloader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addComponents }) => {
addComponents({
'.k-ios-preloader > span': {
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-range.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addVariant, e }) => {
addVariant('range-thumb', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-safe-areas.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities, addBase, theme, e }) => {
const base = {
':root': {
Expand Down
3 changes: 1 addition & 2 deletions src/config/plugin-touch-ripple.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const plugin = require('tailwindcss/plugin');
const hexToRgb = require('./hex-to-rgb.js');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities, addBase, theme }) => {
addBase({
// prettier-ignore
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-touch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities }) => {
const touch = {};
const values = ['pan-x', 'pan-y', 'none', 'manipulation'];
Expand Down
4 changes: 1 addition & 3 deletions src/config/plugin-translucent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
module.exports = (plugin) =>
plugin(({ addUtilities }) => {
addUtilities({
'@supports (backdrop-filter: blur(20px))': {
Expand Down
69 changes: 69 additions & 0 deletions src/configWindicss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const path = require('path');
const plugin = require('windicss/plugin');
const configExtend = require('./config/config-extend.js');
const extendTheme = require('./config/extend-theme.js');

const pluginBase = require('./config/plugin-base.js');
const pluginColors = require('./config/plugin-colors.js');
const pluginPreloader = require('./config/plugin-preloader.js');
const pluginHairlines = require('./config/plugin-hairlines.js');
const pluginTouchRipple = require('./config/plugin-touch-ripple.js');
const pluginIosMaterial = require('./config/plugin-ios-material.js');
const pluginLineClamp = require('./config/plugin-line-clamp.js');
const pluginSafeAreas = require('./config/plugin-safe-areas.js');
const pluginTranslucent = require('./config/plugin-translucent.js');
const pluginRange = require('./config/plugin-range.js');
const pluginTouch = require('./config/plugin-touch.js');
const pluginNoScrollbar = require('./config/plugin-no-scrollbar.js');

const content = `${path.resolve(__dirname)}/**/*.{js,jsx,vue,svelte}`;

const config = (userConfig = {}) => {
const userConfigKonsta = { ...(userConfig.konsta || {}) };
const userConfigModified = { ...userConfig };
delete userConfigModified.konsta;

const konstaConfig = {
colors: {
primary: '#007aff',
...(userConfigKonsta.colors || {}),
},
};

const newConfig = configExtend(
{},
{
theme: {
extend: extendTheme(konstaConfig),
},
plugins: [
pluginBase(plugin, userConfig, konstaConfig),
pluginPreloader(plugin),
pluginIosMaterial(plugin),
pluginHairlines(plugin),
pluginTouchRipple(plugin),
pluginLineClamp(plugin),
pluginSafeAreas(plugin),
pluginTranslucent(plugin),
pluginRange(plugin),
pluginTouch(plugin),
pluginNoScrollbar(plugin),
pluginColors(plugin, konstaConfig),
],
},
userConfigModified
);

if (!newConfig.content) {
newConfig.content = [content];
} else if (Array.isArray(newConfig.content)) {
newConfig.content = [...newConfig.content, content];
} else if (newConfig.content.files) {
newConfig.content.files = [...newConfig.content.files, content];
} else if (!newConfig.content.files) {
newConfig.content.files = [content];
}

return newConfig;
};
module.exports = config;