Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
pleroma-fe
Commits
ec5d8b98
Commit
ec5d8b98
authored
8 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Set colors into config so they can be used for more dynamic styles.
parent
935c0e09
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/config.js
+3
-2
3 additions, 2 deletions
src/modules/config.js
src/services/style_setter/style_setter.js
+19
-9
19 additions, 9 deletions
src/services/style_setter/style_setter.js
with
22 additions
and
11 deletions
src/modules/config.js
+
3
−
2
View file @
ec5d8b98
...
...
@@ -2,7 +2,8 @@ import { set } from 'vue'
import
StyleSetter
from
'
../services/style_setter/style_setter.js
'
const
defaultState
=
{
name
:
'
Pleroma FE
'
name
:
'
Pleroma FE
'
,
colors
:
{}
}
const
config
=
{
...
...
@@ -24,7 +25,7 @@ const config = {
break
case
'
theme
'
:
const
fullPath
=
`/static/css/
${
value
}
`
StyleSetter
.
setStyle
(
fullPath
)
StyleSetter
.
setStyle
(
fullPath
,
commit
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/services/style_setter/style_setter.js
+
19
−
9
View file @
ec5d8b98
const
setStyle
=
(
href
)
=>
{
import
{
times
}
from
'
lodash
'
const
setStyle
=
(
href
,
commit
)
=>
{
/***
What's going on here?
I want to make it easy for admins to style this application. To have
...
...
@@ -23,18 +25,26 @@ const setStyle = (href) => {
const
setDynamic
=
()
=>
{
const
baseEl
=
document
.
createElement
(
'
div
'
)
body
.
appendChild
(
baseEl
)
baseEl
.
setAttribute
(
'
class
'
,
'
base05
'
)
const
base05Color
=
window
.
getComputedStyle
(
baseEl
).
getPropertyValue
(
'
color
'
)
baseEl
.
setAttribute
(
'
class
'
,
'
base08
'
)
const
base08Color
=
window
.
getComputedStyle
(
baseEl
).
getPropertyValue
(
'
color
'
)
let
colors
=
{}
times
(
16
,
(
n
)
=>
{
const
name
=
`base0
${
n
.
toString
(
16
).
toUpperCase
()}
`
baseEl
.
setAttribute
(
'
class
'
,
name
)
const
color
=
window
.
getComputedStyle
(
baseEl
).
getPropertyValue
(
'
color
'
)
colors
[
name
]
=
color
})
commit
(
'
setOption
'
,
{
name
:
'
colors
'
,
value
:
colors
})
body
.
removeChild
(
baseEl
)
const
styleEl
=
document
.
createElement
(
'
style
'
)
head
.
appendChild
(
styleEl
)
const
styleSheet
=
styleEl
.
sheet
body
.
removeChild
(
baseEl
)
styleSheet
.
insertRule
(
`a { color:
${
base08
Color
}
`
,
'
index-max
'
)
styleSheet
.
insertRule
(
`body { color:
${
base05
Color
}
`
,
'
index-max
'
)
styleSheet
.
insertRule
(
`.base05-border { border-color:
${
base05
Color
}
`
,
'
index-max
'
)
styleSheet
.
insertRule
(
`a { color:
${
colors
[
'
base08
'
]
}
`
,
'
index-max
'
)
styleSheet
.
insertRule
(
`body { color:
${
colors
[
'
base05
'
]
}
`
,
'
index-max
'
)
styleSheet
.
insertRule
(
`.base05-border { border-color:
${
colors
[
'
base05
'
]
}
`
,
'
index-max
'
)
body
.
style
.
display
=
'
initial
'
}
cssEl
.
addEventListener
(
'
load
'
,
setDynamic
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment