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
4bb27020
Commit
4bb27020
authored
Jan 28, 2017
by
Cole Bemis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move script to main.js
parent
7ce70f6c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
60 deletions
+59
-60
index.html
index.html
+1
-60
main.js
src/main.js
+58
-0
No files found.
index.html
View file @
4bb27020
...
...
@@ -39,65 +39,6 @@
<
/div
>
</script>
<script>
const
data
=
{
icons
:
[
'
square
'
,
'
circle
'
,
'
rectangle-vertical
'
,
'
rectangle-horizontal
'
]
};
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
);
});
}
});
Vue
.
component
(
'
icon-container
'
,
{
props
:
{
name
:
{
type
:
String
,
required
:
true
}
},
template
:
'
#icon-container-template
'
})
new
Vue
({
el
:
'
#app
'
,
data
:
data
});
</script>
<script
src=
"src/main.js"
></script>
</body>
</html>
\ No newline at end of file
src/main.js
0 → 100644
View file @
4bb27020
const
data
=
{
icons
:
[
'
square
'
,
'
circle
'
,
'
rectangle-vertical
'
,
'
rectangle-horizontal
'
]
};
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
);
});
}
});
Vue
.
component
(
'
icon-container
'
,
{
props
:
{
name
:
{
type
:
String
,
required
:
true
}
},
template
:
'
#icon-container-template
'
})
new
Vue
({
el
:
'
#app
'
,
data
:
data
});
\ 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