Skip to content

Commit

Permalink
feat(prefs): ✨ remove line-height customization for now
Browse files Browse the repository at this point in the history
Will be re-implemented later
  • Loading branch information
alistair3149 committed Apr 25, 2024
1 parent 877406e commit 964a4a5
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 44 deletions.
1 change: 0 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"citizen-tagline-ns-category": "Category page",
"citizen-tagline-user-regdate": "Joined $1",
"prefs-citizen-pagewidth-label": "Page width",
"prefs-citizen-lineheight-label": "Line height",
"prefs-citizen-resetbutton-label": "Reset to default",

"citizen-theme-name": "Color",
Expand Down
1 change: 0 additions & 1 deletion i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"citizen-tagline-ns-category": "Tagline for pages in category namespace",
"citizen-tagline-user-regdate": "Label for registration date in taglines on userpages",
"prefs-citizen-pagewidth-label": "Label for the page width settings",
"prefs-citizen-lineheight-label": "Label for the line height settings",
"prefs-citizen-resetbutton-label": "Label for the reset button that restore default settings",
"citizen-theme-name": "Heading label for setting that allows you to change theme.",
"citizen-theme-description": "Description for theme.",
Expand Down
18 changes: 5 additions & 13 deletions resources/skins.citizen.preferences/skins.citizen.preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ function setIndicator( key, value ) {
*/
function convertForForm( pref ) {
return {
pagewidth: Number( pref.pagewidth.slice( 0, -2 ) ) / 120 - 6,
lineheight: ( pref.lineheight - 1 ) * 10
pagewidth: Number( pref.pagewidth.slice( 0, -2 ) ) / 120 - 6
};
}

Expand All @@ -70,8 +69,7 @@ function getPref() {
const rootStyle = window.getComputedStyle( document.documentElement );

const pref = {
pagewidth: mw.storage.get( PREFIX_KEY + 'pagewidth' ) || rootStyle.getPropertyValue( '--width-layout' ),
lineheight: mw.storage.get( PREFIX_KEY + 'lineheight' ) || rootStyle.getPropertyValue( '--line-height' )
pagewidth: mw.storage.get( PREFIX_KEY + 'pagewidth' ) || rootStyle.getPropertyValue( '--width-layout' )
};

return pref;
Expand All @@ -88,8 +86,7 @@ function setPref() {
formData = Object.fromEntries( new FormData( document.getElementById( CLASS + '-form' ) ) ),
currentPref = convertForForm( getPref() ),
newPref = {
pagewidth: Number( formData[ CLASS + '-pagewidth' ] ),
lineheight: Number( formData[ CLASS + '-lineheight' ] )
pagewidth: Number( formData[ CLASS + '-pagewidth' ] )
};

if ( currentPref.pagewidth !== newPref.pagewidth ) {
Expand All @@ -103,10 +100,6 @@ function setPref() {
mw.storage.set( PREFIX_KEY + 'pagewidth', formattedPageWidth );
setIndicator( 'pagewidth', formattedPageWidth );

} else if ( currentPref.lineheight !== newPref.lineheight ) {
const formattedLineHeight = newPref.lineheight / 10 + 1;
mw.storage.set( PREFIX_KEY + 'lineheight', formattedLineHeight );
setIndicator( 'lineheight', formattedLineHeight );
}

applyPref();
Expand All @@ -118,7 +111,7 @@ function setPref() {
* @return {void}
*/
function resetPref() {
const keys = [ 'pagewidth', 'lineheight' ];
const keys = [ 'pagewidth' ];

// Remove style
if ( document.getElementById( 'citizen-style' ) ) {
Expand Down Expand Up @@ -218,7 +211,6 @@ function getMessages() {
const keys = [
'preferences',
'prefs-citizen-pagewidth-label',
'prefs-citizen-lineheight-label',
'prefs-citizen-resetbutton-label'
],
data = {};
Expand Down Expand Up @@ -249,7 +241,7 @@ function initPanel( event ) {
data = getMessages(),
pref = getPref(),
prefValue = convertForForm( pref ),
keys = [ 'pagewidth', 'lineheight' ];
keys = [ 'pagewidth' ];

// To Mustache is to jQuery sigh
// TODO: Use ES6 template literals when RL does not screw up multiline
Expand Down
21 changes: 0 additions & 21 deletions resources/skins.citizen.preferences/templates/preferences.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@
<option value="10" label=""></option>
</datalist>
</fieldset>
{{! Line height }}
<fieldset class="citizen-pref-item" id="citizen-pref-lineheight">
<label for="citizen-pref-lineheight" class="citizen-pref-item__label">
<span class="citizen-pref-item__title">{{msg-prefs-citizen-lineheight-label}}</span>
<span class="citizen-pref-item__value" id="citizen-pref-lineheight__value"></span>
</label>
<input id="citizen-pref-lineheight__input" name="citizen-pref-lineheight" type="range" max="10" list="citizen-pref-lineheight__tickmarks">
<datalist id="citizen-pref-lineheight__tickmarks" class="citizen-pref__tickmarks">
<option value="0" label="1"></option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
<option value="4"></option>
<option value="5"></option>
<option value="6"></option>
<option value="7"></option>
<option value="8"></option>
<option value="9"></option>
<option value="10" label="2"></option>
</datalist>
</fieldset>
</form>
<button id="citizen-pref-resetbutton">{{msg-prefs-citizen-resetbutton-label}}</button>
</aside>
3 changes: 1 addition & 2 deletions resources/skins.citizen.scripts/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ window.applyPref = () => {

const apply = () => {
const cssProps = {
pagewidth: '--width-layout',
lineheight: '--line-height'
pagewidth: '--width-layout'
};

const injectStyles = ( css ) => {
Expand Down
6 changes: 0 additions & 6 deletions skin.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@
],
"messages": [
"preferences",
"prefs-citizen-theme-label",
"prefs-citizen-theme-option-auto",
"prefs-citizen-theme-option-light",
"prefs-citizen-theme-option-dark",
"prefs-citizen-fontsize-label",
"prefs-citizen-pagewidth-label",
"prefs-citizen-lineheight-label",
"prefs-citizen-resetbutton-label",
"citizen-theme-name",
"citizen-theme-description",
Expand Down

0 comments on commit 964a4a5

Please sign in to comment.