-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
180 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
body.dark { | ||
--jsf-main-bg-color: #222227; | ||
--jsf-modest-bg-color: #333333; | ||
--jsf-border-color: #444444; | ||
--jsf-modest-bg-highlight-color: #444444; | ||
--jsf-validation-color: darkred; | ||
--jsf-main-fg-color: #999999; | ||
background-color: var(--jsf-main-bg-color); | ||
color: var(--jsf-main-fg-color); | ||
} | ||
body.dark input { | ||
background-color: var(--jsf-main-bg-color); | ||
color: var(--jsf-main-fg-color); | ||
} | ||
body.dark input:focus { | ||
background-color: var(--jsf-main-bg-color); | ||
} | ||
body.dark select { | ||
background-color: var(--jsf-main-bg-color); | ||
color: var(--jsf-main-fg-color); | ||
border-color: var(--jsf-border-color); | ||
} | ||
body.dark textarea { | ||
background-color: var(--jsf-main-bg-color); | ||
color: var(--jsf-main-fg-color); | ||
} | ||
body.dark button { | ||
background-color: var(--jsf-modest-bg-color); | ||
color: var(--jsf-main-fg-color); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
body.labelFixed .control { | ||
flex-direction: row; | ||
} | ||
body.labelFixed .control > label { | ||
min-width: 10em; | ||
text-align: end; | ||
margin-right: 1em; | ||
} | ||
body.labelFixed .control > .input { | ||
flex: 1; | ||
} | ||
/* Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=375693 */ | ||
/*body.labelFixed .control > fieldset { | ||
display: block; | ||
width: 100%; | ||
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import * as _ from 'lodash'; | ||
import {JsonFormsHolder} from '../src/core'; | ||
import {changeExample} from './example'; | ||
declare let $; | ||
|
||
export const createStyleSelection = (selectExampleElement: HTMLSelectElement) => { | ||
const styleDiv = document.getElementById('style'); | ||
// create select element for selecting style to be applied | ||
const selectStyle = document.createElement('select'); | ||
['none', 'bootstrap', 'materialize'].forEach(style => { | ||
const option = document.createElement('option'); | ||
option.value = style; | ||
option.label = _.capitalize(style); | ||
option.text = style; | ||
selectStyle.appendChild(option); | ||
}); | ||
selectStyle.onchange = () => { | ||
changeStyle(selectStyle.value); | ||
// re-render the easy way | ||
const currentExample = selectExampleElement.value; | ||
changeExample(currentExample); | ||
}; | ||
const styleLabel = document.createElement('label'); | ||
styleLabel.innerText = 'Style'; | ||
styleDiv.appendChild(styleLabel); | ||
styleDiv.appendChild(selectStyle); | ||
|
||
changeStyle('none'); | ||
} | ||
|
||
|
||
|
||
function changeStyle(style) { | ||
$('select').material_select('destroy'); | ||
if (style === 'bootstrap') { | ||
bootstrap(); | ||
} else if (style === 'materialize') { | ||
material(); | ||
} else { | ||
none(); | ||
} | ||
} | ||
|
||
function none() { | ||
enableLink('example') | ||
} | ||
|
||
function bootstrap() { | ||
enableLink('bootstrap'); | ||
JsonFormsHolder.stylingRegistry.registerMany([ | ||
{ | ||
name: 'button', | ||
classNames: ['btn', 'btn-primary'] | ||
}, | ||
{ | ||
name: 'select', | ||
classNames: ['custom-select'] | ||
}, | ||
]); | ||
$('select').attr('class', JsonFormsHolder.stylingRegistry.getAsClassName('select')); | ||
} | ||
|
||
function material() { | ||
enableLink('materialize'); | ||
JsonFormsHolder.stylingRegistry.register( | ||
'button', | ||
['btn', 'waves-effect', 'waves-light'] | ||
); | ||
JsonFormsHolder.stylingRegistry.unregister('select'); | ||
$('select').material_select(); | ||
} | ||
|
||
/** | ||
* Disables all links and only enables the one containing the wanted href. | ||
* This function assumes that all links are CSS links used for styling purposes. | ||
* | ||
* @param wantedHref a substring of the link's href value, which is to be enabled | ||
*/ | ||
function enableLink(wantedHref: string): void { | ||
const links = $('link').toArray(); | ||
// disable all links | ||
_.forEach(links, link => link.disabled = true); | ||
const wantedLinks = _.filter(links, (link: HTMLLinkElement) => link.href.includes(wantedHref) | ||
|| link.href.includes('dark') || link.href.includes('labelfixed')); | ||
// enable wanted link | ||
_.forEach(wantedLinks, (wantedLink) => {wantedLink.disabled = false; }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const knownThemes : {[key: string]: string} = { | ||
normal: 'Normal Label Top', | ||
dark: 'Dark label Top', | ||
labelFixed: 'Label left Fixed' | ||
}; | ||
const changeTheme = (style: string) => { | ||
document.body.className = style; | ||
}; | ||
export const createThemeSelection = () => { | ||
const themeDiv = document.getElementById('theme'); | ||
|
||
const select = document.createElement('select'); | ||
select.id = 'example_theme'; | ||
Object.keys(knownThemes).forEach(key => { | ||
const style = knownThemes[key]; | ||
const option = document.createElement('option'); | ||
option.value = key; | ||
option.label = style; | ||
option.text = style; | ||
select.appendChild(option); | ||
}); | ||
select.onchange = (ev: Event) => (changeTheme(select.value)); | ||
|
||
const themeLabel = document.createElement('label'); | ||
themeLabel.textContent = 'Theme:'; | ||
themeLabel.htmlFor = 'example_theme'; | ||
|
||
themeDiv.appendChild(themeLabel); | ||
themeDiv.appendChild(select); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.