-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,293 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: setup environment | ||
description: bun setup | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile --ignore-scripts | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
pull_request_target: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup | ||
- run: bun compile | ||
name: compile | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup | ||
- run: bun test | ||
name: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
# Logs | ||
*.log | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# TypeScript cache | ||
# Cache | ||
*.tsbuildinfo | ||
.parcel-cache | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Generated files | ||
**/generated.* | ||
**/.generated | ||
**/*.generated.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"recommendations": [ | ||
"esbenp.prettier-vscode", | ||
"oven.bun-vscode", | ||
"bradlc.vscode-tailwindcss", | ||
"jaaxxx.bun-lockb", | ||
"tamasfe.even-better-toml", | ||
"me-dutour-mathieu.vscode-github-actions", | ||
"christian-kohler.path-intellisense", | ||
"redhat.vscode-yaml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
}, | ||
"editor.quickSuggestions": { | ||
"other": "on", | ||
"comments": "off", | ||
"strings": "on" | ||
}, | ||
"tailwindCSS.colorDecorators": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# contributing to twyx | ||
|
||
First, thank you! Contributors are what make open source go 'round, so your interest is very appreciated. | ||
|
||
## installation | ||
|
||
1. ensure `bun` [is installed](https://bun.sh/) | ||
2. `bun install` | ||
|
||
## adding a framework adapter | ||
|
||
twyx is designed as both a core standalone library and with third-party framework adapters like `twyx/react`. | ||
|
||
To add an adapter for a new framework: | ||
|
||
1. create an appropriately-named file in the `src` directory and integrate `twyx` using the best practices of your framework. | ||
2. try to limit installed packages to the bare minimum | ||
3. add an entry to `package.json "exports"` for the new file | ||
4. add the file to the `compile:lib` script target | ||
5. add the file to `tsconfig.json "include"` | ||
6. add a section to the README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
import * as ReactDOM from "react-dom/client"; | ||
import { twyx, x } from "../src/react"; | ||
|
||
const foo = true; | ||
const className = twyx({ | ||
display: { _: "block", md: "flex" }, | ||
bg: { _: "green-100", dark: { _: "green-900", hover: "green-800" } }, | ||
bg: { _: "gray-100", dark: { _: "gray-900" } }, | ||
color: { _: "gray-900", dark: { _: "gray-100" } }, | ||
h: "screen", | ||
outlineColor: "amber-100/[.50]", | ||
}); | ||
|
||
export default function HelloWorld() { | ||
return ( | ||
<x.p | ||
// TODO: remove need for square brackets | ||
borderRadius={foo ? "[3px]" : "sm"} | ||
// TODO: fix typing to allow for deep objects in JSX | ||
color={{ _: "red-100", dark: { _: "red-900", hover: "red-800" } }} | ||
> | ||
You could say we were made for this. | ||
<x.p className={className} fontSize="xl" p={7}> | ||
<x.span color="yellow-500" fontWeight={700} mr={1}> | ||
twyx | ||
</x.span>{" "} | ||
is tailwind for css people | ||
</x.p> | ||
); | ||
} | ||
|
||
const root = ReactDOM.createRoot(document.body); | ||
|
||
root.render(<HelloWorld />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>twyx demo</title> | ||
<link rel="stylesheet" href="/style.generated.css" /> | ||
<link rel="stylesheet" href="./style.generated.css" /> | ||
<script src="../index.tsx" type="module"></script> | ||
</head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,84 @@ | ||
{ | ||
"name": "twyx", | ||
"author": "Evan Jacobs", | ||
"version": "0.0.0", | ||
"author": "Evan Jacobs <[email protected]> (https://probablyup.com)", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/probablyup/twyx" | ||
}, | ||
"module": ".generated/core.js", | ||
"types": ".generated/src/core.d.ts", | ||
"exports": { | ||
".": "./.generated/core.js", | ||
"./react": "./.generated/react.js", | ||
"./transformer": "./.generated/transformer.js" | ||
".": { | ||
"types": "./.generated/src/core.d.ts", | ||
"import": "./.generated/core.js" | ||
}, | ||
"./react": { | ||
"types": "./.generated/src/react.d.ts", | ||
"import": "./.generated/react.js" | ||
}, | ||
"./transformer": { | ||
"types": "./.generated/transformer.d.ts", | ||
"import": "./.generated/transformer.js" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
".generated", | ||
"README.md", | ||
"LICENSE" | ||
], | ||
"sideEffects": false, | ||
"dependencies": { | ||
"clsx": "^2.0.0", | ||
"csstype": "^3.1.2" | ||
"csstype": "^3.1.2", | ||
"tailwindcss": "^3.3.3" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.8", | ||
"@types/escodegen-jsx": "npm:@types/escodegen", | ||
"@types/react": "^18.2.21", | ||
"@types/react-dom": "^18.2.7", | ||
"@types/react-test-renderer": "^18.0.2", | ||
"ast-types": "^0.14.2", | ||
"bun-types": "^1.0.1", | ||
"bundlemon": "^2.0.2", | ||
"concurrently": "^8.2.1", | ||
"debug": "^4.3.4", | ||
"escodegen-jsx": "^0.1.0-1.4.2dev", | ||
"espree": "^9.6.1", | ||
"prettier": "^3.0.3", | ||
"react": "^18.2.0", | ||
"tailwindcss": "^3.3.3", | ||
"react-dom": "^18.2.0", | ||
"react-test-renderer": "^18.2.0", | ||
"typescript": "^5.2.2", | ||
"unquote": "^1.1.1" | ||
}, | ||
"scripts": { | ||
"compile:tailwind": "tailwindcss -i demo/style.css -o demo/public/style.generated.css --minify" | ||
"prepare": "bun compile:colors", | ||
"prepublishOnly": "bun compile", | ||
"check:unit": "bun test", | ||
"check:size": "bundlemon", | ||
"compile": "bun compile:colors && bun compile:lib && bun compile:transformer && bun compile:types && bun check:size", | ||
"compile:colors": "bun scripts/generate-colors.ts", | ||
"compile:lib": "bun build src/core.ts src/react.tsx --external=* --outdir=.generated --sourcemap=external --minify", | ||
"postcompile:lib": "bun check:size", | ||
"compile:demo:css": "tailwindcss -c tailwind.config.ts -i demo/style.css -o demo/public/style.generated.css --minify", | ||
"compile:demo:js": "parcel build demo/public/index.html --dist-dir demo/public/.generated", | ||
"compile:transformer": "bun build ./transformer.ts --outdir=.generated --sourcemap=external --minify", | ||
"compile:types": "tsc -p tsconfig.build.json", | ||
"dev": "concurrently 'bun --watch scripts/generate-colors.ts' 'parcel demo/public/index.html --dist-dir demo/public/.generated --open' 'bun compile:demo:css --watch'" | ||
}, | ||
"bundlemon": { | ||
"baseDir": ".generated", | ||
"files": [ | ||
{ | ||
"path": "core.js", | ||
"maxSize": "3 kB" | ||
}, | ||
{ | ||
"path": "react.js", | ||
"maxSize": "3 kB" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.