Skip to content

Commit

Permalink
add edge ui common project
Browse files Browse the repository at this point in the history
  • Loading branch information
zizifn committed Jan 1, 2023
1 parent 3350bfb commit 3142e24
Show file tree
Hide file tree
Showing 24 changed files with 373 additions and 75 deletions.
15 changes: 15 additions & 0 deletions apps/cf-page/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { join } = require('path');

// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
// option from your application's configuration (i.e. project.json).
//
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries

module.exports = {
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
},
autoprefixer: {},
},
};
3 changes: 3 additions & 0 deletions apps/cf-page/src/styles.css
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
@tailwind components;
@tailwind base;
@tailwind utilities;
/* You can add global styles to this file, and also import other style files */
17 changes: 17 additions & 0 deletions apps/cf-page/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
const { join } = require('path');

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
join(
__dirname,
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
),
...createGlobPatternsForDependencies(__dirname),
],
theme: {
extend: {},
},
plugins: [],
};
17 changes: 0 additions & 17 deletions apps/deno-vless/src/app/app.spec.tsx

This file was deleted.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/deno-vless/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<script type="module" crossorigin src="/assets/index.fcec86ee.js"></script>
<script type="module" crossorigin src="/assets/index.65634f6c.js"></script>
<link rel="stylesheet" href="/assets/index.5ac34fbb.css">
</head>

Expand Down
5 changes: 3 additions & 2 deletions apps/deno-vless/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
import App from './app/app';
// import App from './app/app';
import { EdgeApp } from 'edge-ui';
import './styles.css';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<App />
<EdgeApp />
</StrictMode>
);
1 change: 1 addition & 0 deletions apps/deno-vless/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
),
...createGlobPatternsForDependencies(__dirname),
'libs/edge-ui/src/lib/*.tsx',
],
theme: {
extend: {},
Expand Down
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"babelrcRoots": ["*"]
}
18 changes: 18 additions & 0 deletions libs/edge-ui/.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 libs/edge-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# edge-ui

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

## Running unit tests

Run `nx test edge-ui` to execute the unit tests via [Vitest](https://vitest.dev/).
15 changes: 15 additions & 0 deletions libs/edge-ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { join } = require('path');

// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
// option from your application's configuration (i.e. project.json).
//
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries

module.exports = {
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
},
autoprefixer: {},
},
};
23 changes: 23 additions & 0 deletions libs/edge-ui/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "edge-ui",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/edge-ui/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/edge-ui/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/vite:test",
"outputs": ["{projectRoot}/coverage"],
"options": {
"passWithNoTests": true
}
}
}
}
1 change: 1 addition & 0 deletions libs/edge-ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/app';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExclamationTriangleIcon, XMarkIcon } from '@heroicons/react/20/solid';
import QRCode from 'qrcode';
import { Fragment, useEffect, useState } from 'react';
import { validate as uuidValidate } from 'uuid';
export function App() {
export function EdgeApp() {
const [text, setText] = useState('');
const [show, setShow] = useState(false);
function handleShare(text: string) {
Expand Down Expand Up @@ -183,7 +183,7 @@ function ShareAnything({
htmlFor="comment"
className="block text-sm font-medium text-gray-700"
>
随意要分享的内容
随意要分享的内容.
</label>
<div className="mt-1">
<textarea
Expand Down Expand Up @@ -262,4 +262,4 @@ function Warning() {
);
}

export default App;
export default EdgeApp;
17 changes: 17 additions & 0 deletions libs/edge-ui/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
const { join } = require('path');

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
join(
__dirname,
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
),
...createGlobPatternsForDependencies(__dirname),
],
theme: {
extend: {},
},
plugins: [],
};
20 changes: 20 additions & 0 deletions libs/edge-ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json"
}
22 changes: 22 additions & 0 deletions libs/edge-ui/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"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": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
19 changes: 19 additions & 0 deletions libs/edge-ui/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["vitest/globals", "node"]
},
"include": [
"vite.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
26 changes: 26 additions & 0 deletions libs/edge-ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
server: {
port: 4200,
host: 'localhost',
},
plugins: [
react(),
viteTsConfigPaths({
root: '../../',
}),
],

test: {
globals: true,
cache: {
dir: '../../node_modules/.vitest',
},
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
},
});
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
],
"sharedGlobals": []
"sharedGlobals": ["{workspaceRoot}/babel.config.json"]
},
"generators": {
"@nrwl/react": {
Expand Down
Loading

0 comments on commit 3142e24

Please sign in to comment.