Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
feather
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
feather
Commits
ab3cc7ef
Commit
ab3cc7ef
authored
Jan 25, 2017
by
Cole Bemis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Vue app
parent
3afa82d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
10 deletions
+87
-10
circle.svg
icons/circle.svg
+1
-0
index.html
index.html
+86
-10
No files found.
icons/circle.svg
0 → 100644
View file @
ab3cc7ef
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"24"
height=
"24"
viewBox=
"0 0 24 24"
fill=
"none"
stroke=
"#000"
stroke-linecap=
"round"
stroke-miterlimit=
"10"
stroke-width=
"2"
><circle
cx=
"12"
cy=
"12"
r=
"10"
/></g></svg>
\ No newline at end of file
index.html
View file @
ab3cc7ef
...
...
@@ -3,23 +3,99 @@
<head>
<meta
charset=
"UTF-8"
>
<title>
Feather
</title>
<style>
body
{
margin
:
0
;
}
.icon
{
display
:
inline-block
;
line-height
:
0
;
}
.icon
>
svg
{
stroke
:
currentColor
;
}
</style>
<script
src=
"https://unpkg.com/vue/dist/vue.js"
></script>
</head>
<body>
<div
class=
"svg-container"
></div>
<div
id=
"app"
>
<icon-container
v-for=
"icon in icons"
:name=
"icon"
></icon-container>
</div>
<script
type=
"text/x-template"
id=
"icon-template"
>
<
div
class
=
"
icon
"
><
/div
>
</script>
<script
type=
"text/x-template"
id=
"icon-container-template"
>
<
div
class
=
"
icon-container
"
>
<
a
:
href
=
"
`./icons/${name}.svg`
"
download
>
<
icon
:
name
=
"
name
"
size
=
"
48
"
><
/icon
>
<
/a
>
<
/div
>
</script>
<script>
const
iconName
=
'
square
'
;
const
data
=
{
icons
:
[
'
square
'
,
'
circle
'
]
};
Vue
.
component
(
'
icon
'
,
{
props
:
{
name
:
{
type
:
String
,
required
:
true
},
size
:
{
type
:
String
,
default
:
'
24
'
}
},
template
:
'
#icon-template
'
,
mounted
()
{
fetch
(
`./icons/
${
this
.
name
}
.svg`
)
.
then
(
response
=>
{
if
(
response
.
ok
)
{
return
response
.
text
();
}
throw
new
Error
(
`Cannot find
${
this
.
name
}
.svg`
);
})
.
then
(
svgText
=>
{
const
svgDocument
=
new
DOMParser
().
parseFromString
(
svgText
,
'
image/svg+xml
'
);
const
svgIcon
=
svgDocument
.
querySelector
(
'
svg
'
).
cloneNode
(
true
);
svgIcon
.
setAttribute
(
'
width
'
,
this
.
size
);
svgIcon
.
setAttribute
(
'
height
'
,
this
.
size
);
this
.
$el
.
appendChild
(
svgIcon
);
})
.
catch
(
error
=>
{
console
.
error
(
error
);
});
}
});
fetch
(
`./icons/
${
iconName
}
.svg`
)
.
then
(
response
=>
response
.
text
())
.
then
(
svgText
=>
{
const
svgDocument
=
new
DOMParser
().
parseFromString
(
svgText
,
'
image/svg+xml
'
);
const
svgIcon
=
svgDocument
.
querySelector
(
'
svg
'
).
cloneNode
(
true
);
const
svgContainer
=
document
.
querySelector
(
'
.svg-container
'
);
Vue
.
component
(
'
icon-container
'
,
{
props
:
{
name
:
{
type
:
String
,
required
:
true
}
},
template
:
'
#icon-container-template
'
})
svgContainer
.
appendChild
(
svgIcon
);
});
new
Vue
({
el
:
'
#app
'
,
data
:
data
});
</script>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment