Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion nx-workspace-emotion/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module.exports = {
projects: ['<rootDir>/apps/web', '<rootDir>/libs/shared-ui'],
projects: [
'<rootDir>/apps/web',
'<rootDir>/libs/shared-ui',
'<rootDir>/libs/tailwind-config',
],
};
4 changes: 0 additions & 4 deletions nx-workspace-emotion/libs/shared-ui/.babelrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { resolve } = require('path');

module.exports = {
twin: {
preset: 'emotion',
config: resolve(__dirname, 'tailwind.config.js'),
},
};
4 changes: 4 additions & 0 deletions nx-workspace-emotion/libs/shared-ui/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: ['@nrwl/react/babel', '@emotion/babel-preset-css-prop'],
plugins: ['babel-plugin-macros'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export const Button = styled.button(
tw`transform transition-transform duration-75`,

// Use the variant grouping feature to add variants to multiple classes
tw`hocus:(scale-105 text-yellow-400)`,
tw`hover:(scale-105)`,

// Custom color from custom tailwind config
tw`hover:(text-zabadoo)`,
Copy link
Author

Choose a reason for hiding this comment

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

Crucially, here's where we're using a custom value set in the theme.


// Use props to conditionally style your components
isPrimary && tw`bg-black text-white border-black`,
Expand Down
3 changes: 3 additions & 0 deletions nx-workspace-emotion/libs/shared-ui/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require('../tailwind-config')],
};
5 changes: 5 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {}
}
7 changes: 7 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# tailwind-config

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test tailwind-config` to execute the unit tests via [Jest](https://jestjs.io).
14 changes: 14 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: 'tailwind-config',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/tailwind-config',
};
5 changes: 5 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@nx-workspace-emotion/tailwind-config",
"version": "0.0.1",
"main": "src/index.js"
}
2 changes: 2 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* eslint-disable no-undef */
module.exports = require('./lib/theme');
10 changes: 10 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/src/lib/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable no-undef */
module.exports = {
theme: {
extend: {
colors: {
zabadoo: 'blue',
Copy link
Author

Choose a reason for hiding this comment

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

Here's where we're defining a special variable, in this case, a brand colour called "zabadoo".

},
},
},
};
13 changes: 13 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
11 changes: 11 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["**/*.spec.ts"],
"include": ["**/*.ts"]
}
15 changes: 15 additions & 0 deletions nx-workspace-emotion/libs/tailwind-config/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/*.d.ts"
]
}
6 changes: 5 additions & 1 deletion nx-workspace-emotion/nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"options": { "cacheableOperations": ["build", "lint", "test", "e2e"] }
}
},
"projects": { "web": { "tags": [] }, "shared-ui": { "tags": [] } }
"projects": {
"web": { "tags": [] },
"shared-ui": { "tags": [] },
"tailwind-config": { "tags": [] }
}
}
1 change: 1 addition & 0 deletions nx-workspace-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@nrwl/jest": "11.2.12",
"@nrwl/linter": "11.2.12",
"@nrwl/next": "11.2.12",
"@nrwl/node": "^11.4.0",
"@nrwl/react": "11.2.12",
"@nrwl/tao": "11.2.12",
"@nrwl/web": "11.2.12",
Expand Down
5 changes: 4 additions & 1 deletion nx-workspace-emotion/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@my-twin-project/shared-ui": ["libs/shared-ui/src/index.ts"]
"@my-twin-project/shared-ui": ["libs/shared-ui/src/index.ts"],
"@nx-workspace-emotion/tailwind-config": [
"libs/tailwind-config/src/index.ts"
]
}
},
"exclude": ["node_modules", "tmp"]
Expand Down
40 changes: 40 additions & 0 deletions nx-workspace-emotion/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,46 @@
}
}
}
},
"tailwind-config": {
"root": "libs/tailwind-config",
"sourceRoot": "libs/tailwind-config/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"libs/tailwind-config/**/*.ts"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": [
"coverage/libs/tailwind-config"
],
"options": {
"jestConfig": "libs/tailwind-config/jest.config.js",
"passWithNoTests": true
}
},
"build": {
"executor": "@nrwl/node:package",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/libs/tailwind-config",
"tsConfig": "libs/tailwind-config/tsconfig.lib.json",
"packageJson": "libs/tailwind-config/package.json",
"main": "libs/tailwind-config/src/index.ts",
"assets": [
"libs/tailwind-config/*.md"
]
}
}
}
}
}
}
Loading