Skip to content

Commit

Permalink
Merge pull request #30 from perimetre/2.1
Browse files Browse the repository at this point in the history
2.1
  • Loading branch information
adarleyjrr authored Mar 24, 2021
2 parents 48413a3 + 9d9826e commit b1a46e7
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 28 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## [2.1.0] - 2021-03-24

### Changes

- Updated setup instructions to use Tailwind's default extractor in purgecss configuration

### Added

- Added new class `pui-container` extending Tailwind's default `container` class, but only allowing maximum width of 1280px instead of allowing up to 1536px
- Added new class `pui-container-large` extending Tailwind's default `container` class

### Fixed

- Fixed bug in postcss purge script extractor method, by changing it for Tailwind's default extractor method
- Fixed a bug in disabled buttons to display a regular cursor on hover

## [2.0.0] - 2021-03-12

### **Breaking changes**
Expand Down
17 changes: 5 additions & 12 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,15 @@ You will need:
+ // postcss-purgecss should always be last before autoprefixer and only run in production
+ ...(process.env.NODE_ENV === 'production' && {
+ '@fullhuman/postcss-purgecss': {
+ extractors: [
+ {
+ // Fix for escaped tailwind prefixes (sm:, lg:, hover:, etc)
+ // https://github.com/tailwindlabs/tailwindcss/issues/391#issuecomment-746829848
+ extractor: (content) => {
+ return content.match(/[A-Za-z0-9-._:\/]+/g) || [];
+ },
+ extensions: ['css', 'js', 'ts', 'tsx']
+ }
+ ],
+ defaultExtractor: (content) => {
+ const extractor = require('tailwindcss/lib/lib/purgeUnusedStyles').tailwindExtractor;
+ const preserved = [...extractor(content)];
+ return preserved;
+ },
+ content: [
+ // All project components
+ './pages/**/*.{js,ts,jsx,tsx}',
+ './src/components/**/*.{js,ts,jsx,tsx}',
+ // Consider all css files imported from other libs
+ './node_modules/react-toastify/dist/ReactToastify.css',
+ // Consider the components in the ui
+ './node_modules/@perimetre/ui/**/*.{js,ts,jsx,tsx,css}',
+ '!./node_modules/@perimetre/ui/**/storybookMappers.tsx' // ignore the storybookMappers.tsx inside @perimetre/ui because that should only be used by the ui package itself
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@perimetre/ui",
"description": "A component library made by @perimetre",
"version": "2.0.0",
"version": "2.1.0",
"repository": {
"type": "git",
"url": "git+https://github.com/perimetre/ui.git"
Expand Down
25 changes: 11 additions & 14 deletions postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ module.exports = {
'postcss-combine-duplicated-selectors': {},
'postcss-flexbugs-fixes': {}, // Required to use the storybook beta with postcss8 and to use with nextjs
'@fullhuman/postcss-purgecss': {
extractors: [
{
/**
* Fix for escaped tailwind prefixes (sm:, lg:, hover:, etc)
* https://github.com/tailwindlabs/tailwindcss/issues/391#issuecomment-746829848
*
* @param content the content to be parsed
*/
extractor: (content) => {
return content.match(/[A-Za-z0-9-._:\/]+/g) || [];
},
extensions: ['css', 'js', 'ts', 'tsx']
}
],
/**
* Use tailwind extractor
*
* @param content the content to be parsed
*/
defaultExtractor: (content) => {
const extractor = require('tailwindcss/lib/lib/purgeUnusedStyles').tailwindExtractor;
const preserved = [...extractor(content)];

return preserved;
},
content: ['./src/**/*.{js,ts,jsx,tsx,css}', './.storybook/**/*.{js,ts,jsx,tsx,css}']
},
// autoprefixer should always be the last one
Expand Down
5 changes: 5 additions & 0 deletions src/components/Button/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
/* Moves the button down a little bit to give feedback */
--tw-translate-y: 0.125rem;
}

&:disabled {
/* Remove pointer */
@apply cursor-default;
}
}

/* The default variant */
Expand Down
12 changes: 12 additions & 0 deletions src/components/Container/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@layer components {
.pui-container {
@apply container;

@screen 2xl {
max-width: 1280px;
}
}
.pui-container-large {
@apply container;
}
}
1 change: 1 addition & 0 deletions src/components/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
@import './HTMLParsedContent';
@import './WYSIWYGInput';
@import './DragFileUploadInput';
@import './Container';

0 comments on commit b1a46e7

Please sign in to comment.