Skip to content

Commit 28baf0a

Browse files
committed
Add button feature with Vue components and styling
Introduced a new "button" feature consisting of reusable Vue components. Created `ButtonApp.vue` and `MyButton.vue` for functionality and styling, and updated routing in `vite.config.js`. Includes dynamic props handling and interaction logic.
1 parent 3d2c7b2 commit 28baf0a

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

button.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Vue</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/button.js"></script>
12+
</body>
13+
</html>

src/button.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {createApp} from "vue";
2+
import ButtonApp from "./components/ButtonApp.vue";
3+
4+
createApp(ButtonApp).mount("#app");

src/components/ButtonApp.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script setup>
2+
3+
import MyButton from "./MyButton.vue";
4+
5+
function clickHandler(){
6+
alert("You click me");
7+
}
8+
</script>
9+
10+
<template>
11+
<MyButton class="button" @click="clickHandler" name="Eko" contoh="Kurniawan"/>
12+
</template>
13+
14+
<style scoped>
15+
.button {
16+
display: inline-block;
17+
padding: 10px 20px;
18+
background-color: #007bff;
19+
color: #fff;
20+
font-size: 16px;
21+
border: none;
22+
border-radius: 4px;
23+
cursor: pointer;
24+
text-align: center;
25+
transition: background-color 0.3s ease, transform 0.2s ease;
26+
}
27+
28+
.button:hover {
29+
background-color: #0056b3;
30+
transform: scale(1.05);
31+
}
32+
33+
.button:active {
34+
background-color: #00408d;
35+
transform: scale(0.98);
36+
}
37+
38+
.button:focus {
39+
outline: 2px solid #80bdff;
40+
outline-offset: 2px;
41+
}
42+
</style>

src/components/MyButton.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script setup>
2+
import {useAttrs} from "vue";
3+
4+
const props = defineProps(["contoh"])
5+
console.info(props)
6+
7+
const attributes = useAttrs();
8+
console.info(attributes);
9+
10+
</script>
11+
12+
<template>
13+
<button>My Button : {{attributes.name}}</button>
14+
</template>
15+
16+
<style scoped>
17+
18+
</style>

vite.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default defineConfig({
1717
contact: "contact.html",
1818
product: "product.html",
1919
note: "note.html",
20+
button: "button.html",
2021
}
2122
}
2223
}

0 commit comments

Comments
 (0)