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(Vanilla Extract): as a future replacement of jss #561

Merged
merged 54 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f841a5e
playroom and storybook working
atabel Oct 20, 2022
f75a192
build
atabel Oct 25, 2022
0a3b84c
Merge branch 'master' into atoledano-vanilla
atabel Oct 25, 2022
0823022
removed unused imports
atabel Oct 25, 2022
1ab5c3e
ssr tests
atabel Oct 25, 2022
36754f6
fix playroom build
atabel Oct 25, 2022
9302619
autoprefixer
atabel Oct 25, 2022
68e3282
comment
atabel Oct 25, 2022
dd14992
added postcss plugin for automatic box-sizing border-box
atabel Oct 25, 2022
f630d09
make postcss work in storybook
atabel Oct 26, 2022
18ff594
fix ts
atabel Oct 26, 2022
e6e8d15
fix vercel deploy
atabel Oct 26, 2022
5cd60b9
update swc
atabel Oct 26, 2022
e28b19f
fix test
atabel Oct 26, 2022
b703449
fix ssr tests
atabel Oct 26, 2022
ac1ad82
fix eslint rule
atabel Oct 27, 2022
8b57721
migrate Box
atabel Oct 27, 2022
bf0df66
revert box
atabel Oct 27, 2022
813a9f5
add lib overhead gzip to stats
atabel Oct 27, 2022
3f6bf11
remove unused eslint directive
atabel Oct 27, 2022
4959f58
setup ssr tests to work with vanilla extract
atabel Oct 28, 2022
3696296
move yarn ci to gh workflow
atabel Oct 28, 2022
97870fa
move ts check after build
atabel Oct 28, 2022
0c561d1
dont render theme styles in unit tests
atabel Oct 31, 2022
60e034a
add comment in storybook config
atabel Oct 31, 2022
e364e14
flex 1
atabel Oct 31, 2022
22c8f14
typo
atabel Oct 31, 2022
b42cb36
mediaqueries and migrated snackbar
atabel Oct 31, 2022
61df2f6
fix preview tools
atabel Oct 31, 2022
37a9cb6
flow types
atabel Oct 31, 2022
505b7ab
Fix dimensions config logic
atabel Nov 2, 2022
ce58c96
fix playroom theme config
atabel Nov 2, 2022
eaac9cf
flow defs
atabel Nov 2, 2022
b5afb04
deprecate theme.mediaQueries
atabel Nov 2, 2022
9100938
deprecate mediaqueries config
atabel Nov 2, 2022
2d91fd1
remove background from sprinkles
atabel Nov 2, 2022
242586a
flow defs
atabel Nov 2, 2022
af44f26
make 3 playroom builds to be able to force mobile/desktop
atabel Nov 2, 2022
443f28c
fix ts
atabel Nov 2, 2022
17e8571
embed VE sytles into js
atabel Nov 2, 2022
24b5c75
Merge branch 'master' into atoledano-vanilla
atabel Nov 2, 2022
0e9df6f
deprecate jss
atabel Nov 2, 2022
4afd417
fix tests
atabel Nov 2, 2022
a95d1d2
Merge branch 'master' into atoledano-vanilla
atabel Nov 3, 2022
ab8e52b
comment vercel builds
atabel Nov 3, 2022
690f2ca
make forceMobile and forceDesktop work in PreviewTools
atabel Nov 3, 2022
ce6ced7
handle false in forceMobile/forceDesktop
atabel Nov 3, 2022
b44bab2
Merge branch 'master' into atoledano-vanilla
atabel Nov 3, 2022
941ed0e
handle false in forceMobile/forceDesktop
atabel Nov 3, 2022
9bb76ba
grammar
atabel Nov 3, 2022
b85347c
Merge branch 'master' into atoledano-vanilla
atabel Nov 4, 2022
039381b
support consummer apps to use VE too
atabel Nov 7, 2022
097ee7b
change .vanilla.css to .mistica-vanilla.css
atabel Nov 7, 2022
1185096
Merge branch 'master' into atoledano-vanilla
atabel Nov 8, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ storybook-static/
.vercel
src/generated/mistica-icons/index.tsx.txt
reports
css/mistica.css
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this file is generated by yarn build


.yarn/*
!.yarn/cache
Expand Down
44 changes: 44 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const path = require('path');
const {VanillaExtractPlugin} = require('@vanilla-extract/webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const replaceBabelWithSwc = (config) => {
// Replace default webpack babel-loader with swc-loader
Expand All @@ -17,9 +19,49 @@ const replaceBabelWithSwc = (config) => {
return config;
};

const addVanillaExtractSupport = (config) => {
config.module.rules.forEach((rule) => {
if (
rule.test &&
(Array.isArray(rule.test)
? rule.test.some((exp) => exp.test('random.css'))
: rule.test.test('random.css'))
) {
const previousExclude = rule.exclude || [];
rule.exclude = [
...(Array.isArray(previousExclude) ? previousExclude : [previousExclude]),
/\.vanilla\.css$/,
];
}
});

config.plugins.push(new VanillaExtractPlugin(), new MiniCssExtractPlugin());
config.module.rules.push({
test: /\.vanilla\.css$/i, // Targets only CSS files generated by vanilla-extract
use: [
MiniCssExtractPlugin.loader,
{
loader: require.resolve('css-loader'),
options: {
url: false, // Required as image imports should be handled via JS/TS import statements
},
},
require.resolve('postcss-loader'),
],
});
};

module.exports = {
stories: ['./welcome-story.js', '../src/**/__stories__/*-story.tsx'],
addons: [
{
name: '@storybook/addon-postcss',
options: {
postcssLoaderOptions: {
implementation: require('postcss'),
},
},
},
'@storybook/addon-links',
{
name: '@storybook/addon-storysource',
Expand All @@ -45,6 +87,8 @@ module.exports = {
ignored: [/node_modules/, /__tests__/, /__acceptance_tests__/, /__screenshot_tests__/],
};

addVanillaExtractSupport(config);

return replaceBabelWithSwc(config);
},
managerWebpack: async (config) => {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/resolve-patch-b4a69197d3-a0dd7d16a8.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions flow-defs/avatar.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

declare export var avatar: string;
declare export var image: string;
7 changes: 7 additions & 0 deletions flow-defs/badge.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @flow

declare export var container: string;
declare export var badge: string;
declare export var badgeNumber: string;
declare export var badgeWithChildren: string;
declare export var badgeBigNumber: string;
6 changes: 6 additions & 0 deletions flow-defs/skins/skin-contract.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @flow
import type {Colors} from './types';

declare export var vars: {
colors: Colors,
};
4 changes: 4 additions & 0 deletions flow-defs/sprinkles.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

declare export var sprinkles: any; // TODO: improve this
export type Sprinkles = any; // TODO: improve this
3 changes: 3 additions & 0 deletions flow-defs/tag.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow

declare export var tag: string;
6 changes: 6 additions & 0 deletions flow-overrides/skins/skin-contract.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @flow
import type {Colors} from './types';

declare export var vars: {
colors: Colors,
};
4 changes: 4 additions & 0 deletions flow-overrides/sprinkles.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

declare export var sprinkles: any; // TODO: improve this
export type Sprinkles = any; // TODO: improve this
1 change: 1 addition & 0 deletions jest.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'!**/__*__/**', // ignore tests, acceptance, stories, etc
],
transform: {
'\\.css\\.ts$': '@vanilla-extract/jest-transform',
'^.+\\.(t|j)sx?$': ['@swc/jest', {...swcConfig, sourceMaps: 'inline'}],
},
coverageReporters: ['json-summary', 'lcov'],
Expand Down
25 changes: 20 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"storybook-for-acceptance-tests": "cross-env NODE_ENV=production yarn storybook --ci 2>&1",
"playroom": "playroom start",
"gen-ts-defs": "rimraf dist-ts && tsc --project tsconfig.production.json --emitDeclarationOnly && cp -r dist-ts/src/* dist && rimraf dist-ts",
"now-build": "yarn storybook-static && ./node_modules/.bin/playroom build && cp img/favicon.ico public/",
"vercel-build": "yarn storybook-static && ./node_modules/.bin/playroom build && cp img/favicon.ico public/",
"storybook-static": "rimraf public && yarn build-storybook -s ./.storybook/css/fonts -o public --quiet",
"serve-static-storybook": "node ./scripts/serve-static-storybook.js",
"detect-circular-dependencies": "npx dpdm --circular src/index.tsx",
Expand Down Expand Up @@ -67,16 +67,17 @@
"@storybook/addon-actions": "6.4.19",
"@storybook/addon-controls": "6.4.19",
"@storybook/addon-links": "6.4.19",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-storysource": "6.4.19",
"@storybook/addon-viewport": "6.4.19",
"@storybook/addons": "6.4.19",
"@storybook/cli": "6.4.19",
"@storybook/components": "6.4.19",
"@storybook/react": "6.4.19",
"@storybook/theming": "6.4.19",
"@swc/cli": "^0.1.56",
"@swc/core": "^1.2.160",
"@swc/jest": "^0.2.20",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.11",
"@swc/jest": "^0.2.23",
"@telefonica/acceptance-testing": "^2.7.0",
"@telefonica/eslint-config": "^1.0.7",
"@telefonica/prettier-config": "^1.1.0",
Expand All @@ -86,12 +87,18 @@
"@testing-library/user-event": "^13.5.0",
"@types/detect-port": "^1.3.2",
"@types/jest-environment-puppeteer": "^4.4.1",
"@types/mini-css-extract-plugin": "^1.2.2",
"@types/mkdirp": "^1.0.2",
"@types/react-autosuggest": "^10.1.5",
"@types/react-router-dom": "^5.3.3",
"@types/react-transition-group": "^4.4.4",
"@types/rimraf": "^3.0.2",
"@types/semver-compare": "^1.0.1",
"@vanilla-extract/jest-transform": "^1.0.1",
"@vanilla-extract/vite-plugin": "^3.6.1",
"@vanilla-extract/webpack-plugin": "^2.2.0",
"@vitejs/plugin-react": "^2.1.0",
"autoprefixer": "^10.4.12",
"axe-html-reporter": "^2.2.3",
"cpx": "^1.5.0",
"cross-env": "^7.0.3",
Expand All @@ -107,8 +114,11 @@
"jest-environment-puppeteer": "^4.4.0",
"jimp": "^0.16.1",
"lint-staged": "^12.3.7",
"mini-css-extract-plugin": "^1.6.2",
"node-fetch": "^2.6.7",
"playroom": "^0.28.0",
"postcss": "^8.4.18",
"postcss-loader": "^4.2.0",
"prettier": "^2.6.1",
"pretty-bytes": "^5.6.0",
"prop-types": "^15.8.1",
Expand All @@ -120,12 +130,17 @@
"semantic-release": "^19.0.2",
"static-server": "^2.2.1",
"swc-loader": "^0.1.15",
"typescript": "^4.6.3"
"typescript": "^4.6.3",
"vite": "^3.1.8",
"vite-plugin-no-bundle": "^1.0.6"
},
"dependencies": {
"@juggle/resize-observer": "^3.3.1",
"@tef-novum/webview-bridge": "^3.8.0",
"@telefonica/libphonenumber": "^2.8.1",
"@vanilla-extract/css": "^1.9.1",
"@vanilla-extract/dynamic": "^2.0.2",
"@vanilla-extract/sprinkles": "^1.5.0",
"classnames": "^2.3.1",
"jss": "^10.9.0",
"jss-plugin-camel-case": "^10.9.0",
Expand Down
16 changes: 15 additions & 1 deletion playroom.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const config = {
module: {
rules: [
{
test: /\.tsx$/,
test: /\.tsx?$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'playroom'),
Expand All @@ -51,6 +51,20 @@ const config = {
test: /(reset|roboto)\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.vanilla\.css$/i,
// Don't process vanilla files from Playroom as they are handled separately.
exclude: /node_modules\/playroom/,
use: [
'style-loader',
{
loader: require.resolve('css-loader'),
options: {
url: false,
},
},
],
},
],
},
}),
Expand Down
4 changes: 4 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// vite automatically apply postcss to css files, like the generated mistica.css file from vanilla extract.
module.exports = {
plugins: [require('autoprefixer'), require('./postcss/box-sizing-border-box')],
};
23 changes: 23 additions & 0 deletions postcss/box-sizing-border-box.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const addBoxSizing = (decl) => {
decl.cloneBefore({prop: 'box-sizing', value: 'border-box'});
};

/**
* @type {import('postcss').PluginCreator}
*/
module.exports = () => {
return {
postcssPlugin: 'box-sizing-border-box',

Declaration: {
width: addBoxSizing,
height: addBoxSizing,
'min-width': addBoxSizing,
'min-height': addBoxSizing,
'max-width': addBoxSizing,
'max-height': addBoxSizing,
},
};
};

module.exports.postcss = true;
16 changes: 2 additions & 14 deletions scripts/compile.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
const childProcess = require('child_process');
const rimraf = require('rimraf');
const execSync = childProcess.execSync;

const run = (command) => {
execSync(command, {stdio: 'inherit'});
};

const compile = () => {
run(`yarn swc src --out-dir dist-es --extensions .tsx`);

[
'__tests__',
'__acceptance_tests__',
'__screenshot_tests__',
'__type_tests__',
'__stories__',
'test-utils',
].forEach((dirName) => {
rimraf.sync(`dist-es/${dirName}`);
});

run(`yarn vite build`);
run(`yarn swc dist-es --out-dir dist -C module.type=commonjs`);
run(`cp dist-es/style.css css/mistica.css`);
};

if (require.main === module) {
Expand Down
Loading