diff --git a/Makefile b/Makefile index c51da711..305db535 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ testcov: test .PHONY: dev dev: - uvicorn demo.server:app --reload + uvicorn python.demo.main:app --reload .PHONY: all all: testcov lint diff --git a/package-lock.json b/package-lock.json index c2b298fe..4db32857 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2323,6 +2323,10 @@ "resolved": "packages/fastui", "link": true }, + "node_modules/fastui-bootstrap": { + "resolved": "packages/fastui-bootstrap", + "link": true + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -4469,11 +4473,18 @@ "react-dom": "^18.2.0" } }, + "packages/fastui-bootstrap": { + "version": "0.0.0", + "dependencies": { + "bootstrap": "^5.3.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "sass": "^1.69.5" + } + }, "packages/vanilla": { "dependencies": { "@vitejs/plugin-react-swc": "^3.3.2", - "bootstrap": "^5.3.2", - "sass": "^1.69.5", "vite": "^4.4.5" } }, diff --git a/package.json b/package.json index bc6d392b..c77bf985 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ ], "scripts": { "dev": "npm run --workspace=vanilla dev", - "build": "rm -rf packages-dist && npm run --workspaces build", + "build": "rm -rf packages-dist && npm run build --workspaces --if-present", "typecheck": "npm run --workspaces typecheck", "lint": "eslint packages --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0", "lint-fix": "npm run lint -- --fix", diff --git a/packages/fastui-bootstrap/package.json b/packages/fastui-bootstrap/package.json new file mode 100644 index 00000000..e94afbeb --- /dev/null +++ b/packages/fastui-bootstrap/package.json @@ -0,0 +1,18 @@ +{ + "name": "fastui-bootstrap", + "version": "0.0.0", + "scripts": { + "build": "tsc", + "typecheck": "tsc --noEmit", + "typewatch": "tsc --noEmit --watch" + }, + "dependencies": { + "bootstrap": "^5.3.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "sass": "^1.69.5" + }, + "peerDependencies": { + "fastui": "0.0.0" + } +} diff --git a/packages/fastui-bootstrap/src/index.tsx b/packages/fastui-bootstrap/src/index.tsx new file mode 100644 index 00000000..6f13c97d --- /dev/null +++ b/packages/fastui-bootstrap/src/index.tsx @@ -0,0 +1,27 @@ +import { ClassNameGenerator, CustomRender } from 'fastui' + +export const customRender: CustomRender = (props) => { + const { type } = props + if (type === 'DisplayPrimitive') { + const { value } = props + if (typeof value === 'boolean') { + return () => <>{value ? '👍' : '👎'}> + } + } +} + +export const classNameGenerator: ClassNameGenerator = (props) => { + const { type } = props + switch (type) { + case 'Page': + return 'container py-4' + case 'Row': + return 'row' + case 'Col': + return 'col' + case 'Button': + return 'btn btn-primary' + case 'Table': + return 'table table-striped' + } +} diff --git a/packages/vanilla/src/main.scss b/packages/fastui-bootstrap/src/main.scss similarity index 100% rename from packages/vanilla/src/main.scss rename to packages/fastui-bootstrap/src/main.scss diff --git a/packages/fastui-bootstrap/tsconfig.json b/packages/fastui-bootstrap/tsconfig.json new file mode 100644 index 00000000..54855eec --- /dev/null +++ b/packages/fastui-bootstrap/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../packages-dist", + "paths": { + "fastui": ["../fastui/src"] + } + }, + "include": ["src"] +} diff --git a/packages/fastui/package.json b/packages/fastui/package.json index b15a529d..b6b81059 100644 --- a/packages/fastui/package.json +++ b/packages/fastui/package.json @@ -2,7 +2,6 @@ "name": "fastui", "version": "0.0.0", "scripts": { - "build": "tsc", "typecheck": "tsc --noEmit", "typewatch": "tsc --noEmit --watch" }, diff --git a/packages/vanilla/package.json b/packages/vanilla/package.json index 3affcc20..c632aad1 100644 --- a/packages/vanilla/package.json +++ b/packages/vanilla/package.json @@ -8,8 +8,6 @@ }, "dependencies": { "@vitejs/plugin-react-swc": "^3.3.2", - "bootstrap": "^5.3.2", - "sass": "^1.69.5", "vite": "^4.4.5" } } diff --git a/packages/vanilla/src/App.tsx b/packages/vanilla/src/App.tsx index fc1d584a..0544fdb7 100644 --- a/packages/vanilla/src/App.tsx +++ b/packages/vanilla/src/App.tsx @@ -1,35 +1,10 @@ -import { FastUI, ClassNameGenerator, CustomRender } from 'fastui' +import { FastUI } from 'fastui' +import * as bootstrap from 'fastui-bootstrap' export default function App() { return (