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(nxdev): add ui-primitives #14481

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions nx-dev/data-access-documents/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/data-access-packages/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/feature-analytics/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/feature-doc-viewer/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/feature-search/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/ui-common/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
2 changes: 1 addition & 1 deletion nx-dev/ui-common/src/lib/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cx from 'classnames';
import Link from 'next/link';
import { cx } from 'nx-dev/ui-primitives';
import {
AnchorHTMLAttributes,
ForwardedRef,
Expand Down
12 changes: 12 additions & 0 deletions nx-dev/ui-conference/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/ui-member-card/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
12 changes: 12 additions & 0 deletions nx-dev/ui-primitives/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions nx-dev/ui-primitives/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions nx-dev/ui-primitives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# nx-dev-ui-primitives

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

## Running unit tests

Run `nx test nx-dev-ui-primitives` to execute the unit tests via [Jest](https://jestjs.io).
16 changes: 16 additions & 0 deletions nx-dev/ui-primitives/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "nx-dev-ui-primitives",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "nx-dev/ui-primitives/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["nx-dev/ui-primitives/**/*.{ts,tsx,js,jsx}"]
}
}
}
}
2 changes: 2 additions & 0 deletions nx-dev/ui-primitives/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './lib/cx';
export * from './lib/use-layout.effect';
11 changes: 11 additions & 0 deletions nx-dev/ui-primitives/src/lib/cx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import classNames from 'classnames';
import { twMerge } from 'tailwind-merge';

/**
* Small wrapper around classNames and twMerge
* It enables conditional and dynamic class usage,
* resolves duplications and conflicts for TailwindCSS
*/
export function cx(...inputs: classNames.ArgumentArray): string {
return twMerge(classNames(inputs));
}
12 changes: 12 additions & 0 deletions nx-dev/ui-primitives/src/lib/use-layout.effect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useLayoutEffect as ReactUseLayoutEffect } from 'react';

/**
* On the server, React emits a warning when calling `useLayoutEffect`.
* This is because neither `useLayoutEffect` nor `useEffect` run on the server.
* We use this safe version which suppresses the warning by replacing it with a noop on the server.
*
* See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
*/
export const useLayoutEffect = (<any>globalThis)?.document
? ReactUseLayoutEffect
: () => void 0;
17 changes: 17 additions & 0 deletions nx-dev/ui-primitives/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
],
"extends": "../../tsconfig.base.json"
}
23 changes: 23 additions & 0 deletions nx-dev/ui-primitives/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../node_modules/@nrwl/react/typings/image.d.ts"
],
"exclude": [
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
12 changes: 12 additions & 0 deletions nx-dev/ui-sponsor-card/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"send": "0.17.1",
"string-width": "^4.2.3",
"strong-log-transformer": "^2.1.0",
"tailwind-merge": "^1.8.1",
"tailwindcss": "3.2.4",
"tslib": "^2.3.0",
"vitest": "^0.25.8",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"@nrwl/workspace/*": ["packages/workspace/*"],
"@nrwl/workspace/testing": ["packages/workspace/testing"],
"nx": ["packages/nx"],
"nx-dev/ui-primitives": ["nx-dev/ui-primitives/src/index.ts"],
"nx/*": ["packages/nx/*"]
}
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23007,6 +23007,11 @@ synckit@^0.8.4:
"@pkgr/utils" "^2.3.1"
tslib "^2.4.0"

tailwind-merge@^1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-1.8.1.tgz#0e56c8afbab2491f72e06381043ffec8b720ba04"
integrity sha512-+fflfPxvHFr81hTJpQ3MIwtqgvefHZFUHFiIHpVIRXvG/nX9+gu2P7JNlFu2bfDMJ+uHhi/pUgzaYacMoXv+Ww==

tailwindcss@3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.2.4.tgz#afe3477e7a19f3ceafb48e4b083e292ce0dc0250"
Expand Down