Skip to content

Commit

Permalink
fixed a persistence issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Fechner authored and Florian Fechner committed Jul 27, 2020
1 parent c15cf23 commit 9035df3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
id="settings-dialog"
language="{{language}}"
temperature-indicator="{{temperatureIndicator}}"
display="{{display}}"
></settings-dialog>

<div class="align-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ class PeriodicTableContent extends Polymer.Element
value: "h"
},
language: String,
temperatureIndicator: String
temperatureIndicator: String,
display:
{
type: String,
notify: true
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,9 @@ class SettingsDialog extends Polymer.mixinBehaviors([Polymer.AppLocalizeBehavior
shell.openExternal(event.target.href);
});
});

this.shadowRoot.querySelector('.display-selection').addEventListener('selected-changed', () =>
{
updateCSSVariables();
});

updateCSSVariables();
}

updateCSSVariables()
{
if(this.display == 'light')
{
document.documentElement.style.setProperty('--primary-color', '#888');
document.documentElement.style.setProperty('--secondary-color', '#000');
document.documentElement.style.setProperty('--background-color', '#fff');
}

if(this.display == 'dark')
{
document.documentElement.style.setProperty('--primary-color', '#eee');
document.documentElement.style.setProperty('--secondary-color', '#fff');
document.documentElement.style.setProperty('--background-color', '#333');
}
}


open()
{
Expand Down
5 changes: 2 additions & 3 deletions periodic-table/periodic-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ <h1>Elements</h1>
</div>
</div>
<div id="periodic-table-content-container">
<periodic-table-content></periodic-table-content>
<periodic-table-content display="{{display}}"></periodic-table-content>
</div>
<div></div>
</iron-pages>



</template>

<!-- Loads JavaScript -->
Expand Down
26 changes: 26 additions & 0 deletions periodic-table/periodic-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ class PeriodicTable extends Polymer.Element
{
type: Number,
value: 0
},
display:
{
type: String,
observer(newValue, oldValue) {

console.log(newValue);
this._updateCSSVariables();
}
}
}
}
Expand Down Expand Up @@ -84,6 +93,23 @@ class PeriodicTable extends Polymer.Element
return symbols[Math.floor(Math.random() * symbols.length)];
}

_updateCSSVariables()
{
if(this.display == 'light')
{
document.documentElement.style.setProperty('--primary-color', '#888');
document.documentElement.style.setProperty('--secondary-color', '#000');
document.documentElement.style.setProperty('--background-color', '#fff');
}

if(this.display == 'dark')
{
document.documentElement.style.setProperty('--primary-color', '#eee');
document.documentElement.style.setProperty('--secondary-color', '#fff');
document.documentElement.style.setProperty('--background-color', '#333');
}
}

_importHref(href)
{
return new Promise((resolve, reject) =>
Expand Down

0 comments on commit 9035df3

Please sign in to comment.