Skip to content

Commit d65979b

Browse files
committed
sketchybtn component added
1 parent d491d56 commit d65979b

File tree

6 files changed

+84
-6
lines changed

6 files changed

+84
-6
lines changed

codeglynuikit-0.0.1.tgz

498 Bytes
Binary file not shown.

demo-app/src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<template>
2-
<SketchyDiv class="pd">INsied</SketchyDiv>
2+
<SketchyDiv class="pd" style="margin-bottom: 10px;">INsied</SketchyDiv>
3+
<SketchyBtn label="Click" style="padding: 10px 5px; font-size: 18px;"/>
34
</template>
45

56
<script setup>
67
import { SketchyDiv } from "codeglynuikit";
78
// import { SketchyDiv } from '../../lib/src';
9+
import { SketchyBtn } from "codeglynuikit";
10+
// import SketchyBtn from "../../lib/src/components/sketchybtn/SketchyBtn.vue";
811
</script>
912

1013
<style>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script>
2+
import { computed, h, onMounted, 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>

lib/src/components/sketchydiv/SketchyDiv.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
onUpdated,
88
ref,
99
useCssModule,
10+
watch,
1011
} from "vue";
1112
import rough from "roughjs";
1213
@@ -66,6 +67,10 @@ export default {
6667
}
6768
return updatedClasses;
6869
});
70+
watch(props, () => {
71+
clearCanvas()
72+
drawDiv()
73+
})
6974
7075
function drawDiv() {
7176
const rc = rough.canvas(canvasRef.value);

lib/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import MyTest from './components/test/MyTest.js'
2-
import SketchyDiv from './components/sketchydiv/SketchyDiv.vue'
1+
import SketchyDiv from "./components/sketchydiv/SketchyDiv.vue";
2+
import SketchyBtn from "./components/sketchybtn/SketchyBtn.vue";
33

4-
export { SketchyDiv }
4+
export { SketchyDiv, SketchyBtn };

lib/vite.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ export default defineConfig({
1313
fileName: "codeglynuikit",
1414
},
1515
rollupOptions: {
16-
external: ["vue", 'roughjs'],
16+
external: ["vue", 'roughjs', 'codeglynuikit'],
1717
output: {
1818
globals: {
1919
vue: "Vue",
20-
roughjs: "roughtjs"
20+
roughjs: "roughtjs",
21+
codeglynuikit: "codeglynuikit"
2122
},
2223
},
2324
},

0 commit comments

Comments
 (0)