Skip to content

Commit f199a49

Browse files
committed
Merge branch 'develop'
2 parents ecb4c58 + 75373bd commit f199a49

File tree

13 files changed

+516
-15
lines changed

13 files changed

+516
-15
lines changed

demo-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"codeglynuikit": "^0.0.1",
12+
"codeglynuikit": "file:../codeglynuikit-0.0.1.tgz",
1313
"vue": "^3.4.31"
1414
},
1515
"devDependencies": {

demo-app/src/App.vue

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
<template>
2-
<h1>Demo App is running</h1>
3-
<MyTest/>
2+
<SketchyDiv class="pd" style="margin-bottom: 10px">INsied</SketchyDiv>
3+
<SketchyBtn
4+
label="Click"
5+
style="padding: 10px 5px; font-size: 18px; margin-bottom: 100px"
6+
/>
7+
<SketchyHLine />
8+
<div>NEXT</div>
9+
<br />
10+
<SketchyTabs v-model="tab">
11+
<SketchyTab name="focuz" label="Focuz Time" />
12+
<SketchyTab name="short" label="Short Break" />
13+
<SketchyTab name="long" label="Long Break" />
14+
</SketchyTabs>
415
</template>
516

617
<script setup>
7-
import { MyTest } from "codeglynuikit"
8-
</script>
18+
import { SketchyDiv, SketchyBtn, SketchyHLine, SketchyTab, SketchyTabs } from "codeglynuikit";
19+
import { ref } from "vue";
20+
21+
const tab = ref("focuz")
22+
23+
</script>
24+
25+
<style>
26+
.pd {
27+
padding: 80px;
28+
}
29+
</style>

demo-app/src/style.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ body {
1111
padding: 2rem;
1212
text-align: center;
1313
}
14-
15-

lib/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ yarn-error.log*
77
pnpm-debug.log*
88
lerna-debug.log*
99

10+
package-lock.json
11+
1012
node_modules
1113
dist
1214
dist-ssr

lib/package-lock.json

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

lib/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919
"preview": "vite preview"
2020
},
2121
"dependencies": {
22+
"roughjs": "^4.6.6",
2223
"vue": "^3.4.31"
2324
},
2425
"devDependencies": {
2526
"@vitejs/plugin-vue": "^5.0.5",
26-
"vite": "^5.3.4"
27+
"vite": "^5.3.4",
28+
"vite-plugin-css-injected-by-js": "^3.5.1"
29+
},
30+
"peerDependencies": {
31+
"roughjs": "^4.6.6"
2732
}
2833
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script>
2+
import { computed, h, ref, useCssModule } from "vue";
3+
import SketchyDiv from "../sketchydiv/SketchyDiv.vue";
4+
5+
export default {
6+
props: {
7+
label: String,
8+
width: {
9+
type: Number,
10+
default: 150,
11+
},
12+
height: {
13+
type: Number,
14+
default: 40,
15+
},
16+
fontSize: {
17+
type: Number,
18+
default: 19,
19+
},
20+
},
21+
22+
setup(props) {
23+
const style = useCssModule();
24+
const classes = computed(() => {
25+
let updatedClasses;
26+
if (props.class) {
27+
updatedClasses = `${style.container}` + " " + props.class;
28+
} else {
29+
updatedClasses = `${style.container}`;
30+
}
31+
32+
return updatedClasses;
33+
});
34+
const finalClasses = ref(classes.value);
35+
const nodeProps = ref({
36+
options: {
37+
seed: 9,
38+
strokeWidth: 2,
39+
hachureGap: 2,
40+
hachureAngle: 0,
41+
},
42+
class: finalClasses,
43+
onmouseenter: hoverCallback,
44+
onmouseleave: unhoverCallback,
45+
});
46+
47+
function hoverCallback() {
48+
nodeProps.value.options.strokeWidth = 6;
49+
}
50+
function unhoverCallback() {
51+
nodeProps.value.options.strokeWidth = 2;
52+
}
53+
54+
return () => h(SketchyDiv, nodeProps.value, { default: () => props.label });
55+
},
56+
};
57+
</script>
58+
59+
<style module>
60+
.container {
61+
text-align: center;
62+
cursor: pointer;
63+
user-select: none;
64+
}
65+
66+
.btnhovered {
67+
color: white;
68+
}
69+
</style>
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<script>
2+
import {
3+
computed,
4+
h,
5+
nextTick,
6+
onMounted,
7+
onUpdated,
8+
ref,
9+
useCssModule,
10+
watch,
11+
} from "vue";
12+
import rough from "roughjs";
13+
14+
export default {
15+
props: {
16+
class: String,
17+
options: {
18+
type: Object,
19+
default: () => ({
20+
seed: 4,
21+
strokeWidth: 2,
22+
fill: null,
23+
roughness: null,
24+
hachureGap: null,
25+
fillStyle: null,
26+
hachureAngle: null,
27+
}),
28+
},
29+
},
30+
31+
setup(props, { slots }) {
32+
const containerRef = ref(null);
33+
const canvasRef = ref(null);
34+
const style = useCssModule();
35+
const size = ref({
36+
width: null,
37+
height: null,
38+
});
39+
const nodeProps = computed(() => ({
40+
ref: containerRef,
41+
class: classes.value,
42+
}));
43+
44+
const options = computed(() => {
45+
const temp = {
46+
seed: props.options.seed,
47+
strokeWidth: props.options.strokeWidth,
48+
fill: props.options.fill,
49+
roughness: props.options.roughness,
50+
hachureGap: props.options.hachureGap,
51+
fillStyle: props.options.fillStyle,
52+
hachureAngle: props.options.hachureAngle,
53+
};
54+
const filterTemp = Object.fromEntries(
55+
Object.entries(temp).filter(
56+
([_, value]) => value !== undefined && value !== null
57+
)
58+
);
59+
return filterTemp;
60+
});
61+
const classes = computed(() => {
62+
let updatedClasses;
63+
if (props.class) {
64+
updatedClasses = `${style.container}` + " " + props.class;
65+
} else {
66+
updatedClasses = `${style.container}`;
67+
}
68+
return updatedClasses;
69+
});
70+
watch(props, () => {
71+
clearCanvas()
72+
drawDiv()
73+
})
74+
75+
function drawDiv() {
76+
const rc = rough.canvas(canvasRef.value);
77+
rc.rectangle(0, 0, size.value.width, size.value.height, options.value);
78+
}
79+
function clearCanvas() {
80+
canvasRef.value
81+
.getContext("2d")
82+
.clearRect(0, 0, size.value.width, size.value.height);
83+
}
84+
85+
onMounted(() => {
86+
nextTick(() => {
87+
size.value.width = containerRef.value.clientWidth;
88+
size.value.height = containerRef.value.clientHeight;
89+
drawDiv();
90+
});
91+
});
92+
onUpdated(() => {
93+
nextTick(() => {
94+
size.value.width = containerRef.value.clientWidth;
95+
size.value.height = containerRef.value.clientHeight;
96+
clearCanvas();
97+
drawDiv();
98+
});
99+
});
100+
101+
102+
103+
return () => {
104+
const child = [
105+
h("canvas", {
106+
ref: canvasRef,
107+
width: size.value.width,
108+
height: size.value.height,
109+
class: style.boxCanvas,
110+
}),
111+
slots.default ? slots.default() : () => [],
112+
];
113+
114+
return h("div", nodeProps.value, { default: () => child });
115+
};
116+
},
117+
};
118+
</script>
119+
120+
<style module>
121+
.container {
122+
position: relative;
123+
/* min-width: 100%;
124+
min-height: 100%; */
125+
}
126+
127+
.boxCanvas {
128+
position: absolute;
129+
z-index: -10;
130+
top: 0;
131+
bottom: 0;
132+
left: 0;
133+
right: 0;
134+
}
135+
136+
137+
</style>

0 commit comments

Comments
 (0)