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 52 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
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ extends:
overrides:
- files: ['*.js']
parser: espree
rules:
import/extensions: [error, {js: never, json: always, css: always}]
Copy link
Contributor

Choose a reason for hiding this comment

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

why JSON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

6 changes: 6 additions & 0 deletions .github/actions/size-stats-message/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
master-lib-overhead:
description: 'Mistica lib size overhead (on master)'
required: true
master-lib-overhead-gzip:
description: 'Mistica lib size overhead gzip (on master)'
required: true
pr-total-js:
description: 'Total JS size (on pr)'
required: true
Expand All @@ -20,6 +23,9 @@ inputs:
pr-lib-overhead:
description: 'Mistica lib size overhead (on pr)'
required: true
pr-lib-overhead-gzip:
description: 'Mistica lib size overhead gzip (on pr)'
required: true
runs:
using: 'node12'
main: 'main.js'
7 changes: 7 additions & 0 deletions .github/actions/size-stats-message/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ const main = async () => {
totalJs: Number(core.getInput('master-total-js')),
withoutIcons: Number(core.getInput('master-js-without-icons')),
libOverhead: Number(core.getInput('master-lib-overhead')),
libOverheadGzip: Number(core.getInput('master-lib-overhead-gzip')),
};
const pr = {
totalJs: Number(core.getInput('pr-total-js')),
withoutIcons: Number(core.getInput('pr-js-without-icons')),
libOverhead: Number(core.getInput('pr-lib-overhead')),
libOverheadGzip: Number(core.getInput('pr-lib-overhead-gzip')),
};

core.setOutput(
Expand All @@ -36,6 +38,11 @@ const main = async () => {
<td>${prettyBytes(master.libOverhead)}
<td>${prettyBytes(pr.libOverhead)}
<td>${prettyBytes(pr.libOverhead - master.libOverhead, {signed: true})}
<tr>
<td><b>Lib overhead (gzip)</b>
<td>${prettyBytes(master.libOverheadGzip)}
<td>${prettyBytes(pr.libOverheadGzip)}
<td>${prettyBytes(pr.libOverheadGzip - master.libOverheadGzip, {signed: true})}
</table>
`
);
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/size-stats/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ output:
description: 'JS size without icons'
lib-overhead:
description: 'Mistica lib size overhead'
lib-overhead-gzip:
description: 'Mistica lib size overhead (gzip)'
runs:
using: 'node12'
main: 'main.js'
1 change: 1 addition & 0 deletions .github/actions/size-stats/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const main = async () => {
core.setOutput('total-js', sizeStats.totalJs);
core.setOutput('js-without-icons', sizeStats.jsWithoutIcons);
core.setOutput('lib-overhead', sizeStats.libOverhead);
core.setOutput('lib-overhead-gzip', sizeStats.libOverheadGzip);
};

main().catch((error) => {
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --immutable-cache

- name: Run tests
run: yarn ci
- run: yarn lint
- run: yarn prettier-check
- run: yarn circular-dependencies
- run: yarn build
- run: yarn ts-check
- run: yarn storybook-static
- run: yarn test --ci
- run: NO_BUILD=true yarn test-ssr --ci
- run: yarn test-acceptance --ci

- name: 'Upload failed screenshot diffs'
uses: './.github/actions/upload-failed-screenshots'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/size-stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
total-js: ${{ steps.stats.outputs.total-js }}
js-without-icons: ${{ steps.stats.outputs.js-without-icons }}
lib-overhead: ${{ steps.stats.outputs.lib-overhead }}
lib-overhead-gzip: ${{ steps.stats.outputs.lib-overhead-gzip }}

steps:
- uses: actions/checkout@v2
Expand All @@ -30,6 +31,7 @@ jobs:
total-js: ${{ steps.stats.outputs.total-js }}
js-without-icons: ${{ steps.stats.outputs.js-without-icons }}
lib-overhead: ${{ steps.stats.outputs.lib-overhead }}
lib-overhead-gzip: ${{ steps.stats.outputs.lib-overhead-gzip }}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -63,9 +65,11 @@ jobs:
master-total-js: ${{ needs.master-size-stats.outputs.total-js }}
master-js-without-icons: ${{ needs.master-size-stats.outputs.js-without-icons }}
master-lib-overhead: ${{ needs.master-size-stats.outputs.lib-overhead }}
master-lib-overhead-gzip: ${{ needs.master-size-stats.outputs.lib-overhead-gzip }}
pr-total-js: ${{ needs.branch-size-stats.outputs.total-js }}
pr-js-without-icons: ${{ needs.branch-size-stats.outputs.js-without-icons }}
pr-lib-overhead: ${{ needs.branch-size-stats.outputs.lib-overhead }}
pr-lib-overhead-gzip: ${{ needs.branch-size-stats.outputs.lib-overhead-gzip }}

- name: Comment on PR
uses: ./.github/shared-actions/novum/comment-pr
Expand Down
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
45 changes: 45 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,50 @@ const replaceBabelWithSwc = (config) => {
return config;
};

const addVanillaExtractSupport = (config) => {
// Look for rules that match CSS files and make them ignore `.vanilla.css` files (CSS files generated by vanilla-extract)
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 +88,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 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.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ Start prototyping interfaces with Mistica components in the
- [Understanding Mistica's layout components](https://github.com/Telefonica/mistica-web/blob/master/doc/layout.md)
- [Working with forms](https://github.com/Telefonica/mistica-web/blob/master/doc/forms.md)
- [Theme config options](https://github.com/Telefonica/mistica-web/blob/master/doc/theme-config.md)
- [Customize media query break points](https://github.com/Telefonica/mistica-web/blob/master/doc/media-queries.md)
- [Customize default texts](https://github.com/Telefonica/mistica-web/blob/master/doc/texts.md)
- [Analytics](https://github.com/Telefonica/mistica-web/blob/master/doc/analytics.md)
- [Style your components](https://github.com/Telefonica/mistica-web/blob/master/doc/styles.md)
Expand Down
29 changes: 0 additions & 29 deletions doc/media-queries.md

This file was deleted.

7 changes: 0 additions & 7 deletions doc/theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ type ThemeConfig = {
analytics?: {
logEvent: (event: TrackingEvent) => Promise<void>;
};
mediaQueries?: {
tabletMinWidth: number;
desktopMinWidth: number;
largeDesktopMinWidth: number;
desktopOrTabletMinHeight: number;
};
Link?: LinkComponent;
useHrefDecorator: () => (href: string) => string;
};
Expand Down Expand Up @@ -56,7 +50,6 @@ Here is a description of every attribute:
into account.
- `texts?`: some copies you can customize. See [customizable texts doc](./texts.md).
- `analytics?`: see [analytics docs](./analytics.md).
- `mediaQueries?`: see [media queries doc](./media-queries.md).
- `Link?`: the `Link` component you want to use by Touchables that use the prop `to`. By default, the lib uses
an anchor tag (`<a>`). Use this prop to use the Link component from ReactRouter, Next.js or any other
library.
Expand Down
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;
1 change: 1 addition & 0 deletions flow-defs/index.js.flow
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

declare export { createUseStyles, getJss, ServerSideStyles } from "./jss";
declare export { vars as skinVars } from "./skins/skin-contract.css";
declare export { default as ThemeContext } from "./theme-context";
declare export { default as ThemeContextProvider } from "./theme-context-provider";
declare export { default as ScreenReaderOnly } from "./screen-reader-only";
Expand Down
21 changes: 21 additions & 0 deletions flow-defs/media-queries.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @flow

declare export var mediaQueriesConfig: {
tabletMinWidth: number,
desktopMinWidth: number,
largeDesktopMinWidth: number,
desktopOrTabletMinHeight: number,
};
declare export var mobile: string;
declare export var tablet: string;
declare export var desktop: string;
declare export var largeDesktop: string;
declare export var tabletOrBigger: string;
declare export var tabletOrSmaller: string;
declare export var desktopOrBigger: string;
declare export var supportsHover: "@media (pointer: fine), (pointer: none)";
/**
* Scopes the styles to touchable devices.
* See: https://stackoverflow.com/questions/12469875/how-to-code-css-media-queries-targeting-all-mobile-devices-and-tablets/42835826#42835826
*/
declare export var touchableOnly: "@media (pointer: coarse), @media (hover: none)";
2 changes: 1 addition & 1 deletion flow-defs/overscroll-color-context.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ declare type ProviderProps = {
children: React.Node,
};
declare export var OverscrollColorProvider: (x: ProviderProps) => React.Node;
declare var OverscrollColor: () => null;
declare var OverscrollColor: () => React.Node;
declare export default typeof OverscrollColor;
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,
};
14 changes: 14 additions & 0 deletions flow-defs/snackbar.css.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @flow

declare export var TRANSITION_TIME_IN_MS: 300;
declare export var snackbar: string;
declare export var snackbarOpen: string;
declare export var wrapper: string;
declare export var wrapperCritical: string;
declare export var wrapperInfo: string;
declare export var wrapperOpen: string;
declare export var content: string;
declare export var button: string;
declare export var longButton: string;
declare export var buttonInfo: string;
declare export var buttonCritical: string;
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;
1 change: 1 addition & 0 deletions flow-defs/theme-context-provider.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare type Props = {
* Once we migrate to React18, we could remove this prop and use the useId hook instead.
*/
providerId?: string,
as?: string,
children?: React.Node,
};
declare var ThemeContextProvider: React.ComponentType<Props>;
Expand Down
16 changes: 8 additions & 8 deletions flow-defs/theme.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ declare var TEXTS_ES: {
carouselPrevButton: string,
};
declare export var getTexts: (locale: Locale) => typeof TEXTS_ES;
declare export var NAVBAR_HEIGHT_MOBILE: 56;
declare export var NAVBAR_HEIGHT_DESKTOP: 80;
declare export var dimensions: {
headerMobileHeight: number,
headerDesktopHeight: number,
};
declare export var mediaQueriesConfig: {
tabletMinWidth: number,
desktopMinWidth: number,
largeDesktopMinWidth: number,
desktopOrTabletMinHeight: number,
};
declare export { mediaQueriesConfig } from "./media-queries.css";
declare type LinkComponent = React.ComponentType<{
style?: CssStyle,
className?: string,
Expand Down Expand Up @@ -99,8 +96,12 @@ export type ThemeConfig = {
eventFormat?: EventFormat,
},
dimensions?: {
headerMobileHeight: number,
headerMobileHeight: number | "mistica",
},

/**
* @deprecated in future versions, mistica won't allow to configure media query breakpoints.
*/
mediaQueries?: {
tabletMinWidth: number,
desktopMinWidth: number,
Expand Down Expand Up @@ -139,6 +140,5 @@ export type Theme = {
isIos: boolean,
useHrefDecorator: () => (href: string) => string,
};
declare export {};

import { type CssStyle } from "./__css_types__.js.flow";
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
Loading