Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
88811bd1
Commit
88811bd1
authored
Oct 04, 2017
by
Leopoldthecoder
Committed by
杨奕
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update docs theme switcher
parent
e2be799e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
examples/components/theme-picker.vue
examples/components/theme-picker.vue
+32
-17
No files found.
examples/components/theme-picker.vue
View file @
88811bd1
...
@@ -28,7 +28,8 @@
...
@@ -28,7 +28,8 @@
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
chalk
:
''
,
chalk
:
''
,
// content of theme-chalk css
docs
:
''
,
// content of docs css
theme
:
ORIGINAL_THEME
theme
:
ORIGINAL_THEME
};
};
},
},
...
@@ -38,29 +39,43 @@
...
@@ -38,29 +39,43 @@
if
(
typeof
val
!==
'
string
'
)
return
;
if
(
typeof
val
!==
'
string
'
)
return
;
const
themeCluster
=
this
.
getThemeCluster
(
val
.
replace
(
'
#
'
,
''
));
const
themeCluster
=
this
.
getThemeCluster
(
val
.
replace
(
'
#
'
,
''
));
const
originalCluster
=
this
.
getThemeCluster
(
oldVal
.
replace
(
'
#
'
,
''
));
const
originalCluster
=
this
.
getThemeCluster
(
oldVal
.
replace
(
'
#
'
,
''
));
const
handler
=
()
=>
{
const
getHandler
=
(
text
,
id
)
=>
{
const
originalCluster
=
this
.
getThemeCluster
(
ORIGINAL_THEME
.
replace
(
'
#
'
,
''
));
return
()
=>
{
let
newStyle
=
this
.
updateStyle
(
this
.
chalk
,
originalCluster
,
themeCluster
);
const
originalCluster
=
this
.
getThemeCluster
(
ORIGINAL_THEME
.
replace
(
'
#
'
,
''
));
let
newStyle
=
this
.
updateStyle
(
text
,
originalCluster
,
themeCluster
);
let
styleTag
=
document
.
getElementById
(
'
theme-style
'
);
if
(
!
styleTag
)
{
let
styleTag
=
document
.
getElementById
(
id
);
styleTag
=
document
.
createElement
(
'
style
'
);
if
(
!
styleTag
)
{
styleTag
.
setAttribute
(
'
id
'
,
'
theme-style
'
);
styleTag
=
document
.
createElement
(
'
style
'
);
document
.
head
.
appendChild
(
styleTag
);
styleTag
.
setAttribute
(
'
id
'
,
id
);
}
document
.
head
.
appendChild
(
styleTag
);
styleTag
.
innerText
=
newStyle
;
}
styleTag
.
innerText
=
newStyle
;
};
};
};
const
chalkHandler
=
getHandler
(
this
.
chalk
,
'
chalk-style
'
);
const
docsHandler
=
getHandler
(
this
.
docs
,
'
docs-style
'
);
if
(
!
this
.
chalk
)
{
if
(
!
this
.
chalk
)
{
this
.
getChalkString
(
handler
);
this
.
getCSSString
(
`https://unpkg.com/element-ui@
${
version
}
/lib/theme-chalk/index.css`
,
chalkHandler
);
}
else
{
chalkHandler
();
}
if
(
!
this
.
docs
)
{
const
links
=
[].
filter
.
call
(
document
.
querySelectorAll
(
'
link
'
),
link
=>
{
return
/docs
\.
.+
\.
css/
.
test
(
link
.
href
||
''
);
});
links
[
0
]
&&
this
.
getCSSString
(
links
[
0
].
href
,
docsHandler
);
}
else
{
}
else
{
h
andler
();
docsH
andler
();
}
}
const
styles
=
[].
slice
.
call
(
document
.
querySelectorAll
(
'
style
'
))
const
styles
=
[].
slice
.
call
(
document
.
querySelectorAll
(
'
style
'
))
.
filter
(
style
=>
{
.
filter
(
style
=>
{
const
text
=
style
.
innerText
;
const
text
=
style
.
innerText
;
return
new
RegExp
(
oldVal
).
test
(
text
)
&&
!
/Chalk Variables/
.
test
(
text
);
return
new
RegExp
(
oldVal
,
'
i
'
).
test
(
text
)
&&
!
/Chalk Variables/
.
test
(
text
);
});
});
styles
.
forEach
(
style
=>
{
styles
.
forEach
(
style
=>
{
const
{
innerText
}
=
style
;
const
{
innerText
}
=
style
;
...
@@ -79,7 +94,7 @@
...
@@ -79,7 +94,7 @@
return
newStyle
;
return
newStyle
;
},
},
getC
halkString
(
callback
)
{
getC
SSString
(
url
,
callback
)
{
const
xhr
=
new
XMLHttpRequest
();
const
xhr
=
new
XMLHttpRequest
();
xhr
.
onreadystatechange
=
()
=>
{
xhr
.
onreadystatechange
=
()
=>
{
if
(
xhr
.
readyState
===
4
&&
xhr
.
status
===
200
)
{
if
(
xhr
.
readyState
===
4
&&
xhr
.
status
===
200
)
{
...
@@ -87,7 +102,7 @@
...
@@ -87,7 +102,7 @@
callback
();
callback
();
}
}
};
};
xhr
.
open
(
'
GET
'
,
`https://unpkg.com/element-ui@
${
version
}
/lib/theme-chalk/index.css`
);
xhr
.
open
(
'
GET
'
,
url
);
xhr
.
send
();
xhr
.
send
();
},
},
...
...
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