File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ import { type } from 'arktype'
2+ import { defineComponent } from 'sciux-laplace'
3+
4+ const CanvasType = type ( {
5+ width : 'number' ,
6+ height : 'number' ,
7+ origin : 'number[]' ,
8+ } )
9+
10+ export default defineComponent < 'canvas' , typeof CanvasType . infer > ( ( attrs ) => {
11+ return {
12+ name : 'canvas' ,
13+ attrs : CanvasType ,
14+ defaults : {
15+ origin : [ 0 , 0 ] ,
16+ } ,
17+ setup ( children ) {
18+ const svg = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'svg' )
19+ svg . setAttribute ( 'viewBox' , `0 0 ${ attrs . width . value } ${ attrs . height . value } ` )
20+ svg . setAttribute ( 'width' , '100%' )
21+ svg . style . aspectRatio = ( attrs . width . value / attrs . height . value ) . toString ( )
22+ const root = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'g' )
23+ root . setAttribute ( 'transform' , `translate(${ attrs . origin . value . join ( ',' ) } )` )
24+ root . append ( ...children ( ) )
25+ svg . append ( root )
26+ return svg
27+ } ,
28+ }
29+ } )
Original file line number Diff line number Diff line change 1+ /**
2+ * `<table>` component examples
3+ * ```
4+ * <table caption="The table description" align="horizon" :columns="3">
5+ * <link>a link could be a part of item</link>
6+ * <canvas></canvas> // A canvas also could
7+ * Hello world! // A pure-text node also
8+ * // Auto enter to next table line because the max columns is `3`
9+ * <each-node-can-be/>
10+ * </table>
11+ * ```
12+ */
13+
114import { size } from '@sciux/layout'
215import { type } from 'arktype'
316import { defineComponent , toValue } from 'sciux-laplace'
You can’t perform that action at this time.
0 commit comments