You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/cookbook/editable-svg-icons.md
+28-29Lines changed: 28 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,27 +4,27 @@ type: cookbook
4
4
order: 4
5
5
---
6
6
7
-
## Base Example
7
+
## Contoh Dasar
8
8
9
-
There are many ways to create an SVG Icon System, but one method that takes advantage of Vue's capabilities is to create editable inline icons as components. Some of the advantages of this way of working is:
9
+
Ada banyak cara untuk membuat Sistem Ikon SVG, tetapi satu metode yang memanfaatkan kemampuan Vue adalah membuat ikon inline yang dapat diedit sebagai komponen. Beberapa keuntungan dari cara kerja ini adalah:
10
10
11
-
*They are easy to edit on the fly
12
-
*They are animatable
13
-
*You can use standard props and defaults to keep them to a typical size or alter them if you need to
14
-
*They are inline, so no HTTP requests are necessary
15
-
*They can be made accessible dynamically
11
+
*mudah diedit dengan cepat
12
+
* animatable
13
+
*Anda dapat menggunakan alat peraga standar dan standar untuk menjaganya tetap pada ukuran tipikal atau mengubahnya jika perlu
14
+
*sebaris, sehingga tidak ada permintaan HTTP yang diperlukan
15
+
*dapat diakses secara dinamis
16
16
17
-
First, we'll create a folder for all of the icons, and name them in a standardized fashion for easy retrieval:
17
+
Pertama, kami akan membuat folder untuk semua ikon, dan menamainya dengan cara yang terstandarisasi untuk pengambilan yang mudah:
18
18
19
19
> components/icons/IconBox.vue
20
20
> components/icons/IconCalendar.vue
21
21
> components/icons/IconEnvelope.vue
22
22
23
-
Here's an example repo to get you going, where you can see the entire setup: [https://github.com/sdras/vue-sample-svg-icons/](https://github.com/sdras/vue-sample-svg-icons/)
23
+
Berikut ini contoh repo untuk memulai, tempat Anda dapat melihat seluruh pengaturan: [https://github.com/sdras/vue-sample-svg-icons/](https://github.com/sdras/vue-sample-svg-icons/)
We'll create a base icon (`IconBase.vue`) component that uses a slot.
27
+
Kami akan membuat komponen ikon dasar (`IconBase.vue`) yang menggunakan slot.
28
28
29
29
```html
30
30
<template>
@@ -45,10 +45,9 @@ We'll create a base icon (`IconBase.vue`) component that uses a slot.
45
45
</svg>
46
46
</template>
47
47
```
48
+
Anda dapat menggunakan ikon dasar ini sebagai- satu-satunya hal yang perlu Anda perbarui adalah `viewBox` tergantung pada` viewBox` ikon Anda. Di Base Source Code, kami membuat `width`,` height`, `iconColor`, dan nama ikon alat peraga sehingga dapat diperbarui secara dinamis dengan alat peraga. Nama akan digunakan untuk konten `<title>` dan `id` untuk aksesibilitas.
48
49
49
-
You can use this base icon as is- the only thing you might need to update is the `viewBox` depending on the `viewBox` of your icons. In the base, we're making the `width`, `height`, `iconColor`, and name of the icon props so that it can be dynamically updated with props. The name will be used for both the `<title>` content and its `id` for accessibility.
50
-
51
-
Our script will look like this, we'll have some defaults so that our icon will be rendered consistently unless we state otherwise:
50
+
Skrip kami akan terlihat seperti ini, kami akan memiliki beberapa default sehingga ikon kami akan ditampilkan secara konsisten kecuali kami menyatakan sebaliknya:
52
51
53
52
```js
54
53
exportdefault {
@@ -73,15 +72,15 @@ export default {
73
72
}
74
73
```
75
74
76
-
The`currentColor`property that's the default on the fill will make the icon inherit the color of whatever text surrounds it. We could also pass in a different color as a prop if we wish.
75
+
Properti`currentColor`yang merupakan default pada form isian akan membuat ikon mewarisi warna teks apa pun yang mengelilinginya. Kita juga bisa memberikan warna berbeda sebagai penyangga jika kita mau.
77
76
78
-
We can use it like so, with the only contents of `IconWrite.vue`containing the paths inside the icon:
77
+
Kita dapat menggunakannya seperti itu, dengan satu-satunya konten `IconWrite.vue`yang berisi path di dalam ikon:
Keeping icons in components comes in very handy when you'd like to animate them, especially on an interaction. Inline SVGs have the highest support for interaction of any method. Here's a very basic example of an icon that's animated on click:
108
+
Menyimpan ikon dalam komponen sangat berguna ketika Anda ingin menghidupkannya, terutama pada saat interaksi. SVG sebaris memiliki dukungan tertinggi untuk interaksi metode apa pun. Berikut adalah contoh yang sangat mendasar dari ikon yang dianimasikan saat klik:
110
109
111
110
```html
112
111
<template>
@@ -161,27 +160,27 @@ export default {
161
160
}
162
161
```
163
162
164
-
We're applying`refs`to the groups of paths we need to move, and as both sides of the scissors have to move in tandem, we'll create a function we can reuse where we'll pass in the `refs`. The use of GreenSock helps resolve animation support and `transform-origin`issues across browser.
163
+
Kami menerapkan`refs`ke grup jalur yang perlu kami pindahkan, dan karena kedua sisi gunting harus bergerak bersamaan, kami akan membuat fungsi yang dapat kami gunakan kembali di mana kami akan melewati`refs`. Penggunaan GreenSock membantu menyelesaikan dukungan animasi dan masalah `transformasi-origin`di seluruh browser.
165
164
166
-
<pdata-height="300"data-theme-id="0"data-slug-hash="dJRpgY"data-default-tab="result"data-user="Vue"data-embed-version="2"data-pen-title="Editable SVG Icon System: Animated icon"class="codepen">See the Pen <ahref="https://codepen.io/team/Vue/pen/dJRpgY/">Editable SVG Icon System: Animated icon</a> by Vue (<ahref="https://codepen.io/Vue">@Vue</a>) on <ahref="https://codepen.io">CodePen</a>.</p><scriptasyncsrc="https://production-assets.codepen.io/assets/embed/ei.js"></script>
165
+
<pdata-height="300"data-theme-id="0"data-slug-hash="dJRpgY"data-default-tab="result"data-user="Vue"data-embed-version="2"data-pen-title="Editable SVG Icon System: Animated icon"class="codepen">Lihat the Pen <ahref="https://codepen.io/team/Vue/pen/dJRpgY/">Sistem Ikon SVG yang Dapat Diedit: Ikon animasi</a> by Vue (<ahref="https://codepen.io/Vue">@Vue</a>) di <ahref="https://codepen.io">CodePen</a>.</p><scriptasyncsrc="https://production-assets.codepen.io/assets/embed/ei.js"></script>
167
166
168
-
<pstyle="margin-top:-30px">Pretty easily accomplished! And easy to update on the fly.</p>
167
+
<pstyle="margin-top:-30px">Sangat mudah dicapai! Dan mudah untuk memperbarui dengan cepat Saat Berjalan(Eksekusi).</p>
169
168
170
-
You can see more animated examples in the repo [here](https://github.com/sdras/vue-sample-svg-icons/)
169
+
Anda dapat melihat lebih banyak contoh animasi di repo [here](https://github.com/sdras/vue-sample-svg-icons/)
171
170
172
-
## Additional Notes
171
+
## Catatan Tambahan
173
172
174
-
Designers may change their minds. Product requirements change. Keeping the logic for the entire icon system in one base component means you can quickly update all of your icons and have it propagate through the whole system. Even with the use of an icon loader, some situations require you to recreate or edit every SVG to make global changes. This method can save you that time and pain.
173
+
Desainer dapat berubah pikiran. Persyaratan produk berubah. Menyimpan logika untuk seluruh sistem ikon dalam satu komponen dasar berarti Anda dapat dengan cepat memperbarui semua ikon Anda dan menyebarkannya ke seluruh sistem. Bahkan dengan penggunaan ikon loader, beberapa situasi mengharuskan Anda untuk membuat ulang atau mengedit setiap SVG untuk membuat perubahan global. Metode ini dapat menghemat waktu dan rasa sakit Anda.
175
174
176
-
## When To Avoid This Pattern
175
+
## Kapan Harus Menghindari Pola Ini
177
176
178
-
This type of SVG icon system is really useful when you have a number of icons that are used in different ways throughout your site. If you're repeating the same icon many times on one page (e.g. a giant table a delete icon in each row), it might make more sense to have all of the sprites compiled into a sprite sheet and use `<use>`tags to load them.
177
+
Jenis sistem ikon SVG ini sangat berguna ketika Anda memiliki sejumlah ikon yang digunakan dengan berbagai cara di seluruh situs Anda. Jika Anda mengulangi ikon yang sama berkali-kali pada satu halaman (misalnya tabel raksasa ikon hapus di setiap baris), mungkin lebih masuk akal untuk membuat semua sprite dikompilasi menjadi sprite sheet dan menggunakan tag `<use>`tag untuk memuatnya.
179
178
180
-
## Alternative Patterns
179
+
## Pola Alternatif
181
180
182
-
Other tooling to help manage SVG icons includes:
181
+
Perkakas lain untuk membantu mengelola ikon SVG termasuk:
These tools bundle SVGs at compile time, but make them a little harder to edit during runtime, because `<use>`tags can have strange cross-browser issues when doing anything more complex. They also leave you with two nested`viewBox`properties and thus two coordinate systems. This makes the implementation a little more complex.
186
+
Alat-alat ini membundel SVG pada saat waktu kompilasi, tetapi membuatnya sedikit lebih sulit untuk diedit saat runtime, karena tag `<use>`dapat memiliki masalah lintas-browser yang aneh ketika melakukan sesuatu yang lebih kompleks. Mereka juga meninggalkan Anda dengan dua properti`viewBox`yang bersarang dan dengan demikian dua sistem koordinat. Ini membuat implementasinya sedikit lebih kompleks.
0 commit comments