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

chore(atomic): migrate to Tailwindcss v3 #1718

Merged
merged 5 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2,800 changes: 1,496 additions & 1,304 deletions packages/atomic/package-lock.json

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@
"focus-visible": "^5.2.0",
"i18next": "^20.2.2",
"i18next-http-backend": "^1.2.2",
"stencil-inline-svg": "^1.1.0",
"tailwindcss": "^2.2.19"
"stencil-inline-svg": "^1.1.0"
},
"devDependencies": {
"@babel/core": "7.15.8",
"@fullhuman/postcss-purgecss": "4.0.3",
"@monaco-editor/react": "4.3.1",
"@rollup/plugin-alias": "3.1.8",
"@rollup/plugin-replace": "2.4.2",
"@stencil/angular-output-target": "^0.4.0",
"@stencil/core": "2.11.0",
"@stencil/core": "2.13.0",
"@stencil/postcss": "2.1.0",
"@stencil/react-output-target": "^0.2.0",
"@storybook/addon-a11y": "6.3.12",
Expand All @@ -85,9 +83,9 @@
"@types/escape-html": "1.0.1",
"@types/jest": "26.0.24",
"@types/lodash": "4.14.176",
"@types/postcss-import": "12.0.1",
"@types/postcss-import": "14.0.0",
"@types/puppeteer": "5.4.4",
"autoprefixer": "10.4.0",
"autoprefixer": "10.4.2",
"axe-core": "4.3.5",
"babel-loader": "8.2.3",
"cross-fetch": "3.1.4",
Expand All @@ -104,13 +102,14 @@
"monaco-editor-webpack-plugin": "6.0.0",
"ncp": "2.0.0",
"patch-package": "^6.4.7",
"postcss-focus-visible": "6.0.1",
"postcss-focus-visible": "6.0.4",
"postcss-import": "14.0.2",
"postcss-mixins": "8.1.0",
"postcss-mixins": "9.0.1",
"postcss-nested": "5.0.6",
"puppeteer": "9.1.1",
"react": "16.14.0",
"rollup-plugin-html": "0.2.1"
"rollup-plugin-html": "0.2.1",
"tailwindcss": "3.0.19"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why it was a dependency ?

Copy link
Member

Choose a reason for hiding this comment

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

Well, hum, I think it can indeed be seen as a dev dependency, because it's not actually "shipped" to our clients, like they won't actually download and install tailwind when they npm install @coveo/atomic

},
"license": "Apache-2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class AtomicBreadbox implements InitializableComponent {
text: this.bindings.i18n.t('filters'),
})}
</span>
<div class="relative flex-grow">
<div class="relative grow">
<ul
class={`flex gap-1 ${
this.isCollapsed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ export class AtomicPager implements InitializableComponent {
part="previous-button"
disabled={!this.pagerState.hasPreviousPage}
>
<atomic-icon
icon={ArrowRight}
class="w-5 transform rotate-180"
></atomic-icon>
<atomic-icon icon={ArrowRight} class="w-5 rotate-180"></atomic-icon>
</Button>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Rating: FunctionalComponent<RatingProps> = (props) => {
return (
<atomic-icon
icon={props.icon}
class={`flex-shrink-0 ${active ? 'icon-active' : 'icon-inactive'}`}
class={`shrink-0 ${active ? 'icon-active' : 'icon-inactive'}`}
style={{width: iconSize, height: iconSize}}
></atomic-icon>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class AtomicRefineModal implements InitializableComponent {
</h1>,
<div class="relative">
<select
class="btn-outline-neutral w-full cursor-pointer text-lg font-bold flex-grow appearance-none rounded-lg px-6 py-5"
class="btn-outline-neutral w-full cursor-pointer text-lg font-bold grow appearance-none rounded-lg px-6 py-5"
part="select"
aria-label={this.bindings.i18n.t('sort-by')}
onChange={(option) => this.select(option)}
Expand Down Expand Up @@ -271,7 +271,7 @@ export class AtomicRefineModal implements InitializableComponent {
>
<div class="px-6">{this.renderHeader()}</div>
<hr class="border-neutral"></hr>
<div class="overflow-auto px-6 flex-grow">
<div class="overflow-auto px-6 grow">
<div class="adjust-for-scroll-bar">
<aside class="centered">
{this.renderSort()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class AtomicSearchBox {
placeholder={this.bindings.i18n.t('search')}
aria-label={this.bindings.i18n.t('search-box')}
type="text"
class="h-full outline-none bg-transparent flex-grow px-4 py-3.5 text-neutral-dark placeholder-neutral-dark text-lg"
class="h-full outline-none bg-transparent grow px-4 py-3.5 text-neutral-dark placeholder-neutral-dark text-lg"
value={this.searchBoxState.value}
onFocus={() => this.onFocus()}
onBlur={() => this.clearSuggestions()}
Expand Down Expand Up @@ -379,7 +379,7 @@ export class AtomicSearchBox {
private renderInputContainer() {
const isLoading = this.searchBoxState.isLoading;
return (
<div class="flex-grow flex items-center">
<div class="grow flex items-center">
{this.renderInput()}
{isLoading && (
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const FacetHeader: FunctionalComponent<FacetHeaderProps> = (props) => {
>
<atomic-icon
part="label-button-icon"
class="w-3 self-center flex-shrink-0 ml-4"
class="w-3 self-center shrink-0 ml-4"
icon={props.isCollapsed ? ArrowTopIcon : ArrowBottomIcon}
></atomic-icon>
</Button>,
Expand Down
5 changes: 3 additions & 2 deletions packages/atomic/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import alias from '@rollup/plugin-alias';
import path from 'path';
import html from 'rollup-plugin-html';
import {inlineSvg} from 'stencil-inline-svg';

import tailwind from 'tailwindcss';
import postcssNesting from 'postcss-nested';
import tailwind from 'tailwindcss';
import tailwindNesting from 'tailwindcss/nesting';
import atImport from 'postcss-import';
import focusVisible from 'postcss-focus-visible';
import autoprefixer from 'autoprefixer';
Expand Down Expand Up @@ -113,6 +113,7 @@ export const config: Config = {
plugins: [
atImport(),
mixins(),
tailwindNesting(),
Copy link
Contributor Author

@ThibodeauJF ThibodeauJF Feb 8, 2022

Choose a reason for hiding this comment

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

We have to use tailwindcss/nesting & put it before tailwind() for it to work, we get errors in the other case, it's reusing postcss-nested underneath.

Copy link
Contributor Author

@ThibodeauJF ThibodeauJF Feb 8, 2022

Choose a reason for hiding this comment

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

With this, we are getting an issue with mixins & nesting, the following doesn't work (same pattern as used in result templates):

/* Mixin with nesting */
@define-mixin test-mixin {
  input {
    background-color: red;
  }
}

div {
  @mixin test-mixin;
}

The fix is to reuse postcss-nested a second time after tailwind() like we did before. 🍔

tailwind(),
focusVisible(),
postcssNesting(),
Expand Down
23 changes: 1 addition & 22 deletions packages/atomic/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
const plugin = require('tailwindcss/plugin');
const isDevWatch = process.argv.indexOf('--dev') > -1;

module.exports = {
mode: 'jit', // Still some issues for reloading styles with jit mode https://github.com/ionic-team/stencil-postcss/pull/35
purge: {
content: ['./src/**/*.tsx', './src/**/*.css'],
enabled: !isDevWatch,
},
darkMode: false, // or 'media' or 'class'
content: ['./src/**/*.tsx'],
theme: {
extend: {
colors: {
Expand Down Expand Up @@ -79,21 +73,6 @@ module.exports = {
sans: `var(--atomic-font-family)`,
},
},
variants: {
extend: {
textColor: ['visited', 'group-focus', 'disabled', 'focus-visible'],
borderColor: ['disabled', 'focus-visible'],
cursor: ['disabled'],
borderWidth: ['focus-visible'],
backgroundColor: ['group-focus', 'focus-visible'],
borderRadius: ['first', 'last'],
textDecoration: ['focus-visible'],
ringColor: ['focus-visible'],
ringWidth: ['focus-visible'],
outline: ['focus-visible'],
outlineColor: ['focus-visible'],
},
},
plugins: [
plugin(function ({addUtilities, theme, variants}) {
addUtilities(
Expand Down