Skip to content

Commit a85e005

Browse files
committed
feat: link
1 parent 00074a1 commit a85e005

File tree

7 files changed

+116
-0
lines changed

7 files changed

+116
-0
lines changed

packages/widget/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@sciux/widget`
2+
3+
Widgets for SciuxKit

packages/widget/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@sciux/widget",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"description": "Widgets for SciuxKit",
6+
"author": "BijonAI <info@bijon.ai>",
7+
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/bijonai/lib.git"
11+
},
12+
"bugs": "https://github.com/bijonai/lib/issues",
13+
"keywords": [],
14+
"exports": {
15+
".": {
16+
"types": "./src/index.ts",
17+
"import": "./dist/index.js"
18+
}
19+
},
20+
"main": "./dist/index.mjs",
21+
"module": "./dist/index.mjs",
22+
"types": "./dist/index.d.mts",
23+
"files": [
24+
"dist"
25+
],
26+
"scripts": {
27+
"build": "tsup",
28+
"dev": "tsup --watch",
29+
"prepublishOnly": "nr build",
30+
"start": "tsx src/index.ts"
31+
},
32+
"dependencies": {
33+
"@sciux/layout": "workspace:^",
34+
"@vue/reactivity": "^3.5.14",
35+
"arktype": "^2.1.20",
36+
"sciux-laplace": "latest"
37+
}
38+
}

packages/widget/src/index.ts

Whitespace-only changes.

packages/widget/src/link.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { type } from 'arktype'
2+
import { defineComponent, toValue } from 'sciux-laplace'
3+
4+
const T = type({
5+
target: 'string',
6+
}).partial()
7+
8+
export default defineComponent<'link', typeof T.infer>((attrs, _context) => {
9+
return {
10+
name: 'link',
11+
attrs: T,
12+
setup(children) {
13+
const element = document.createElement('a')
14+
element.href = toValue(attrs.target) ?? ''
15+
element.append(...children())
16+
return element
17+
},
18+
}
19+
})

packages/widget/src/table.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { size } from '@sciux/layout'
2+
import { type } from 'arktype'
3+
import { defineComponent, toValue } from 'sciux-laplace'
4+
5+
const BaseTableType = type({
6+
caption: 'string',
7+
inset: 'number',
8+
})
9+
const HorizonTableType = type({
10+
align: `'horizon'`,
11+
columns: 'number',
12+
})
13+
const VerticalTableType = type({
14+
align: `'vertical'`,
15+
rows: 'number',
16+
})
17+
18+
const TableType = type.merge(BaseTableType, HorizonTableType, VerticalTableType).partial()
19+
20+
export default defineComponent<'table', typeof TableType.infer>((attrs, _context) => {
21+
return {
22+
name: 'table',
23+
attrs: TableType,
24+
setup(_childrenResolver) {
25+
const table = document.createElement('table')
26+
table.style.inset = size(toValue(attrs.inset) ?? 'md')
27+
// const children = childrenResolver()
28+
return table
29+
},
30+
}
31+
})

packages/widget/tsup.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'tsup'
2+
3+
export default defineConfig({
4+
entry: ['./src/index.ts'],
5+
outDir: './dist',
6+
format: 'esm',
7+
dts: true,
8+
sourcemap: true,
9+
clean: true,
10+
})

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)