Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
3ef51435
Commit
3ef51435
authored
Mar 18, 2019
by
Rob Stupay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Theme choices in an array
parent
59a0e6d2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
73 deletions
+66
-73
editor.js
src/app/editor/editor.js
+0
-2
settings-tab.js
src/app/tabs/settings-tab.js
+24
-36
theme-chooser.js
src/app/ui/styles-guide/theme-chooser.js
+42
-35
No files found.
src/app/editor/editor.js
View file @
3ef51435
...
@@ -104,8 +104,6 @@ class Editor {
...
@@ -104,8 +104,6 @@ class Editor {
this
.
editor
.
setShowPrintMargin
(
false
)
this
.
editor
.
setShowPrintMargin
(
false
)
this
.
editor
.
resize
(
true
)
this
.
editor
.
resize
(
true
)
this
.
setTheme
()
this
.
editor
.
setOptions
({
this
.
editor
.
setOptions
({
enableBasicAutocompletion
:
true
,
enableBasicAutocompletion
:
true
,
enableLiveAutocompletion
:
true
enableLiveAutocompletion
:
true
...
...
src/app/tabs/settings-tab.js
View file @
3ef51435
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
remixLib
=
require
(
'remix-lib'
)
var
tooltip
=
require
(
'../ui/tooltip'
)
var
tooltip
=
require
(
'../ui/tooltip'
)
var
copyToClipboard
=
require
(
'../ui/copy-to-clipboard'
)
var
copyToClipboard
=
require
(
'../ui/copy-to-clipboard'
)
var
styleGuide
=
require
(
'../ui/styles-guide/theme-chooser'
)
var
styleGuide
=
require
(
'../ui/styles-guide/theme-chooser'
)
var
Storage
=
remixLib
.
Storage
var
EventManager
=
require
(
'../../lib/events'
)
var
EventManager
=
require
(
'../../lib/events'
)
var
css
=
require
(
'./styles/settings-tab-styles'
)
var
css
=
require
(
'./styles/settings-tab-styles'
)
import
{
ApiFactory
}
from
'remix-plugin'
import
{
ApiFactory
}
from
'remix-plugin'
...
@@ -19,7 +16,6 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -19,7 +16,6 @@ module.exports = class SettingsTab extends ApiFactory {
this
.
_view
=
{
/* eslint-disable */
this
.
_view
=
{
/* eslint-disable */
el
:
null
,
el
:
null
,
optionVM
:
null
,
personal
:
null
,
warnPersonalMode
:
null
,
generateContractMetadata
:
null
,
optionVM
:
null
,
personal
:
null
,
warnPersonalMode
:
null
,
generateContractMetadata
:
null
,
theme
:
{
dark
:
null
,
light
:
null
,
clean
:
null
},
config
:
{
config
:
{
general
:
null
,
themes
:
null
general
:
null
,
themes
:
null
}
}
...
@@ -29,10 +25,8 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -29,10 +25,8 @@ module.exports = class SettingsTab extends ApiFactory {
}
}
initTheme
()
{
initTheme
()
{
const
themeStorage
=
new
Storage
(
'style:'
)
this
.
currentTheme
=
styleGuide
.
currentTheme
()
this
.
currentTheme
=
themeStorage
.
get
(
'theme'
)
||
'light'
}
}
get
profile
()
{
get
profile
()
{
return
{
return
{
displayName
:
'settings'
,
displayName
:
'settings'
,
...
@@ -45,6 +39,24 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -45,6 +39,24 @@ module.exports = class SettingsTab extends ApiFactory {
location
:
'swapPanel'
location
:
'swapPanel'
}
}
}
}
createThemeCheckies
()
{
let
themes
=
styleGuide
.
getThemes
()
function
onswitchTheme
(
event
,
name
)
{
styleGuide
.
switchTheme
(
name
)
}
if
(
themes
)
{
return
yo
`<div class="card-text themes-container">
${
themes
.
map
((
aTheme
)
=>
{
let
el
=
yo
`<div class="
${
css
.
frow
}
form-check
${
css
.
crow
}
">
<input type="radio" onchange=
${
event
=>
{
onswitchTheme
(
event
,
aTheme
.
name
)
}}
class
=
"align-middle form-check-input"
name
=
"theme"
id
=
"${aTheme.name}"
>
<
label
class
=
"form-check-label"
for
=
"${aTheme.name}"
>
$
{
aTheme
.
name
}
(
${
aTheme
.
quality
}
)</label>
</div>`
if
(
this
.
currentTheme
===
aTheme
.
name
)
el
.
querySelector
(
'input'
).
setAttribute
(
'checked'
,
'checked'
)
return
el
})}
</div>`
}
}
render
()
{
render
()
{
const
self
=
this
const
self
=
this
...
@@ -57,7 +69,6 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -57,7 +69,6 @@ module.exports = class SettingsTab extends ApiFactory {
var
gistAddToken
=
yo
`<input class="
${
css
.
savegisttoken
}
btn btn-sm btn-primary" id="savegisttoken" onclick=
${()
=>
{
this
.
config
.
set
(
'settings/gist-access-token'
,
gistAccessToken
.
value
);
tooltip
(
'Access token saved'
)
}}
value
=
"Save"
type
=
"button"
>
`
var
gistAddToken
=
yo
`<input class="
${
css
.
savegisttoken
}
btn btn-sm btn-primary" id="savegisttoken" onclick=
${()
=>
{
this
.
config
.
set
(
'settings/gist-access-token'
,
gistAccessToken
.
value
);
tooltip
(
'Access token saved'
)
}}
value
=
"Save"
type
=
"button"
>
`
var gistRemoveToken = yo`
<
input
class
=
"btn btn-sm btn-primary"
id
=
"removegisttoken"
onclick
=
$
{()
=>
{
gistAccessToken
.
value
=
''
;
this
.
config
.
set
(
'settings/gist-access-token'
,
''
);
tooltip
(
'Access token removed'
)
}}
value
=
"Remove"
type
=
"button"
>
`
var gistRemoveToken = yo`
<
input
class
=
"btn btn-sm btn-primary"
id
=
"removegisttoken"
onclick
=
$
{()
=>
{
gistAccessToken
.
value
=
''
;
this
.
config
.
set
(
'settings/gist-access-token'
,
''
);
tooltip
(
'Access token removed'
)
}}
value
=
"Remove"
type
=
"button"
>
`
this._view.gistToken = yo`
<
div
class
=
"${css.checkboxText}"
>
$
{
gistAccessToken
}${
copyToClipboard
(()
=>
this
.
config
.
get
(
'settings/gist-access-token'
))}${
gistAddToken
}${
gistRemoveToken
}
</div>`
this._view.gistToken = yo`
<
div
class
=
"${css.checkboxText}"
>
$
{
gistAccessToken
}${
copyToClipboard
(()
=>
this
.
config
.
get
(
'settings/gist-access-token'
))}${
gistAddToken
}${
gistRemoveToken
}
</div>`
//
this
.
_view
.
optionVM
=
yo
`<input onchange=
${
onchangeOption
}
class="align-middle form-check-input" id="alwaysUseVM" type="checkbox">`
this
.
_view
.
optionVM
=
yo
`<input onchange=
${
onchangeOption
}
class="align-middle form-check-input" id="alwaysUseVM" type="checkbox">`
if
(
this
.
config
.
get
(
'settings/always-use-vm'
))
this
.
_view
.
optionVM
.
setAttribute
(
'checked'
,
''
)
if
(
this
.
config
.
get
(
'settings/always-use-vm'
))
this
.
_view
.
optionVM
.
setAttribute
(
'checked'
,
''
)
this
.
_view
.
personal
=
yo
`<input onchange=
${
onchangePersonal
}
id="personal" type="checkbox" class="align-middle form-check-input">`
this
.
_view
.
personal
=
yo
`<input onchange=
${
onchangePersonal
}
id="personal" type="checkbox" class="align-middle form-check-input">`
...
@@ -74,12 +85,10 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -74,12 +85,10 @@ module.exports = class SettingsTab extends ApiFactory {
this
.
_view
.
pluginInput
=
yo
`<textarea rows="4" cols="70" id="plugininput" type="text" class="
${
css
.
pluginTextArea
}
" ></textarea>`
this
.
_view
.
pluginInput
=
yo
`<textarea rows="4" cols="70" id="plugininput" type="text" class="
${
css
.
pluginTextArea
}
" ></textarea>`
this
.
_view
.
theme
.
light
=
yo
`<input onchange=
${
onswitch2lightTheme
}
class="align-middle form-check-input" name="theme" id="themeLight" type="radio">`
this
.
_view
.
themes
=
styleGuide
.
getThemes
()
this
.
_view
.
theme
.
dark
=
yo
`<input onchange=
${
onswitch2darkTheme
}
class="align-middle form-check-input" name="theme" id="themeDark" type="radio">`
this
.
_view
.
themesCheckBoxes
=
this
.
createThemeCheckies
()
this
.
_view
.
theme
.
clean
=
yo
`<input onchange=
${
onswitch2cleanTheme
}
class="align-middle form-check-input" name="theme" id="themeClean" type="radio">`
this
.
_view
.
theme
[
this
.
currentTheme
].
setAttribute
(
'checked'
,
'checked'
)
this
.
_view
.
config
.
homePage
=
yo
`
this
.
_view
.
config
.
homePage
=
yo
`
<div class="
${
css
.
info
}
card">
<div class="
${
css
.
info
}
card">
<div class="card-body">
<div class="card-body">
<h6 class="
${
css
.
title
}
card-title">Home</h6>
<h6 class="
${
css
.
title
}
card-title">Home</h6>
...
@@ -126,20 +135,7 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -126,20 +135,7 @@ module.exports = class SettingsTab extends ApiFactory {
<div class="
${
css
.
info
}
card">
<div class="
${
css
.
info
}
card">
<div class="card-body">
<div class="card-body">
<h6 class="
${
css
.
title
}
card-title">Themes</h6>
<h6 class="
${
css
.
title
}
card-title">Themes</h6>
<div class="card-text">
${
this
.
_view
.
themesCheckBoxes
}
<div class="
${
css
.
frow
}
form-check
${
css
.
crow
}
">
${
this
.
_view
.
theme
.
light
}
<label class="form-check-label" for="themeLight">Light Theme</label>
</div>
<div class="
${
css
.
frow
}
form-check
${
css
.
crow
}
">
${
this
.
_view
.
theme
.
dark
}
<label class="form-check-label" for="themeDark">Dark Theme</label>
</div>
<div class="
${
css
.
frow
}
form-check
${
css
.
crow
}
">
${
this
.
_view
.
theme
.
clean
}
<label class="form-check-label" for="themeClean">Clean Theme</label>
</div>
</div>
</div>
</div>
</div>`
</div>`
this
.
_view
.
el
=
yo
`
this
.
_view
.
el
=
yo
`
...
@@ -156,18 +152,10 @@ module.exports = class SettingsTab extends ApiFactory {
...
@@ -156,18 +152,10 @@ module.exports = class SettingsTab extends ApiFactory {
function
onchangeOption
(
event
)
{
function
onchangeOption
(
event
)
{
self
.
config
.
set
(
'settings/always-use-vm'
,
!
self
.
config
.
get
(
'settings/always-use-vm'
))
self
.
config
.
set
(
'settings/always-use-vm'
,
!
self
.
config
.
get
(
'settings/always-use-vm'
))
}
}
function
onswitch2darkTheme
(
event
)
{
styleGuide
.
switchTheme
(
'dark'
)
}
function
onswitch2lightTheme
(
event
)
{
styleGuide
.
switchTheme
(
'light'
)
}
function
onswitch2cleanTheme
(
event
)
{
styleGuide
.
switchTheme
(
'clean'
)
}
function
onchangePersonal
(
event
)
{
function
onchangePersonal
(
event
)
{
self
.
config
.
set
(
'settings/personal-mode'
,
!
self
.
config
.
get
(
'settings/personal-mode'
))
self
.
config
.
set
(
'settings/personal-mode'
,
!
self
.
config
.
get
(
'settings/personal-mode'
))
}
}
styleGuide
.
switchTheme
()
styleGuide
.
switchTheme
()
return
this
.
_view
.
el
return
this
.
_view
.
el
}
}
...
...
src/app/ui/styles-guide/theme-chooser.js
View file @
3ef51435
var
Storage
=
require
(
'remix-lib'
).
Storage
var
Storage
=
require
(
'remix-lib'
).
Storage
var
EventEmitter
=
require
(
'events'
)
var
EventEmitter
=
require
(
'events'
)
// Boostrap themes
// TODO : Put it somewhere else
// TODO : Put it somewhere else
const
themes
=
{
const
themes
=
[
dark
:
'https://bootstrap.themes.guide/darkster/theme.min.css'
,
{
name
:
'cerulean'
,
quality
:
'light'
,
url
:
'https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cerulean/bootstrap.min.css'
},
light
:
'https://bootstrap.themes.guide/herbie/theme.min.css'
,
{
name
:
'materia'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/materia/bootstrap.min.css'
},
clean
:
'https://bootstrap.themes.guide/fresca/theme.min.css'
{
name
:
'litera'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/litera/bootstrap.min.css'
},
}
{
name
:
'cosmo'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/cosmo/bootstrap.min.css'
},
// Used for the scroll color
{
name
:
'flatly'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/flatly/bootstrap.min.css'
},
const
themeVariable
=
{
{
name
:
'lux'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/lux/bootstrap.min.css'
},
dark
:
'dark'
,
{
name
:
'spacelab'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/spacelab/bootstrap.min.css'
},
light
:
'light'
,
{
name
:
'yeti'
,
quality
:
'light'
,
url
:
'https://bootswatch.com/4/yeti/bootstrap.min.css'
},
clean
:
'light'
{
name
:
'darkly'
,
quality
:
'dark'
,
url
:
'https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/darkly/bootstrap.min.css'
},
}
{
name
:
'slate'
,
quality
:
'dark'
,
url
:
'https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/slate/bootstrap.min.css'
}
]
const
defaultTheme
=
themes
[
0
].
name
module
.
exports
=
{
module
.
exports
=
{
event
:
new
EventEmitter
(),
event
:
new
EventEmitter
(),
c
hooser
:
function
()
{
c
urrentTheme
:
function
()
{
const
themeStorage
=
new
Storage
(
'style:'
)
const
themeStorage
=
new
Storage
(
'style:'
)
if
(
themeStorage
.
exists
(
'theme'
))
{
if
(
themeStorage
.
exists
(
'theme'
))
{
if
(
themeStorage
.
get
(
'theme'
)
===
'dark'
)
{
const
currThemeObj
=
this
.
isThere
(
themeStorage
.
get
(
'theme'
))
document
.
getElementById
(
'theme-link'
).
setAttribute
(
'href'
,
themes
[
'dark'
])
return
currThemeObj
?
currThemeObj
.
name
:
defaultTheme
document
.
documentElement
.
style
.
setProperty
(
'--theme'
,
'dark'
)
}
else
if
(
themeStorage
.
get
(
'theme'
)
===
'clean'
)
{
document
.
getElementById
(
'theme-link'
).
setAttribute
(
'href'
,
themes
[
'clean'
])
document
.
documentElement
.
style
.
setProperty
(
'--theme'
,
'light'
)
}
else
{
document
.
getElementById
(
'theme-link'
).
setAttribute
(
'href'
,
themes
[
'light'
])
document
.
documentElement
.
style
.
setProperty
(
'--theme'
,
'light'
)
}
}
else
{
}
else
{
document
.
getElementById
(
'theme-link'
).
setAttribute
(
'href'
,
themes
[
'light'
])
return
defaultTheme
document
.
documentElement
.
style
.
setProperty
(
'--theme'
,
'light'
)
}
}
},
},
isThere
:
function
(
themeName
)
{
// returns an object
return
themes
.
find
(
obj
=>
{
return
obj
.
name
===
themeName
})
},
getThemes
:
function
()
{
return
themes
},
switchTheme
:
function
(
theme
)
{
switchTheme
:
function
(
theme
)
{
var
themeStorage
=
new
Storage
(
'style:'
)
let
themeStorage
=
new
Storage
(
'style:'
)
if
(
theme
)
themeStorage
.
set
(
'theme'
,
theme
)
if
(
theme
)
{
else
{
themeStorage
.
set
(
'theme'
,
theme
)
theme
=
themeStorage
.
get
(
'theme'
)
}
let
theTheme
if
(
theme
)
{
theTheme
=
theme
}
else
{
theTheme
=
this
.
currentTheme
()
}
}
if
(
!
theme
)
theme
=
'light'
let
themeObj
=
this
.
isThere
(
theTheme
)
if
(
theme
s
[
theme
]
)
{
if
(
theme
Obj
)
{
document
.
getElementById
(
'theme-link'
).
setAttribute
(
'href'
,
theme
s
[
theme
]
)
document
.
getElementById
(
'theme-link'
).
setAttribute
(
'href'
,
theme
Obj
.
url
)
document
.
documentElement
.
style
.
setProperty
(
'--theme'
,
theme
Variable
[
theme
]
)
document
.
documentElement
.
style
.
setProperty
(
'--theme'
,
theme
Obj
.
quality
)
this
.
event
.
emit
(
'switchTheme'
,
theme
Variable
[
theme
]
)
this
.
event
.
emit
(
'switchTheme'
,
theme
Obj
.
quality
)
}
}
}
}
}
}
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