mirror of
https://github.com/apankrat/nullboard.git
synced 2025-08-12 08:04:07 +02:00
switch to calc() for --lh
This commit is contained in:
@@ -129,8 +129,7 @@
|
|||||||
--ff: f-barlow, sans-serif;
|
--ff: f-barlow, sans-serif;
|
||||||
|
|
||||||
--fs: 11; /* font-size */
|
--fs: 11; /* font-size */
|
||||||
--lh: 15; /* line-height */
|
--lh: calc( var(--fs) * 1.25 ); /* line-height */
|
||||||
|
|
||||||
--fs-head: 13.6; /* font-size of board heading */
|
--fs-head: 13.6; /* font-size of board heading */
|
||||||
--fs-nops: 9; /* font-size of the note ops */
|
--fs-nops: 9; /* font-size of the note ops */
|
||||||
--lw: calc(20 * var(--fs) + 30); /* .list width */
|
--lw: calc(20 * var(--fs) + 30); /* .list width */
|
||||||
@@ -150,14 +149,6 @@
|
|||||||
--lw: calc(20 * var(--fs) + 40); /* .list width */
|
--lw: calc(20 * var(--fs) + 40); /* .list width */
|
||||||
}
|
}
|
||||||
|
|
||||||
/***/
|
|
||||||
html.f-maven-pro {
|
|
||||||
--ff: f-maven-pro, sans-serif;
|
|
||||||
--fs: 12;
|
|
||||||
--fs-head: 13;
|
|
||||||
--lw: calc(20 * var(--fs) + 47); /* .list width */
|
|
||||||
}
|
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
html.f-open-sans {
|
html.f-open-sans {
|
||||||
--ff: f-open-sans, sans-serif;
|
--ff: f-open-sans, sans-serif;
|
||||||
@@ -175,6 +166,14 @@
|
|||||||
--lw: calc(22 * var(--fs) + 40); /* .list width */
|
--lw: calc(22 * var(--fs) + 40); /* .list width */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***/
|
||||||
|
html.f-maven-pro {
|
||||||
|
--ff: f-maven-pro, sans-serif;
|
||||||
|
--fs: 12;
|
||||||
|
--fs-head: 13;
|
||||||
|
--lw: calc(20 * var(--fs) + 47); /* .list width */
|
||||||
|
}
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
html, body, h1, textarea, input {
|
html, body, h1, textarea, input {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -3229,8 +3228,7 @@
|
|||||||
if (conf.lineHeight)
|
if (conf.lineHeight)
|
||||||
setLineHeight(conf.lineHeight);
|
setLineHeight(conf.lineHeight);
|
||||||
|
|
||||||
updateFontSize();
|
updateVars();
|
||||||
updateLineHeight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFontLoaded(f, ok)
|
function onFontLoaded(f, ok)
|
||||||
@@ -3274,30 +3272,32 @@
|
|||||||
$list.removeClass('active');
|
$list.removeClass('active');
|
||||||
$list.filter('[font="' + font + '"]').addClass('active');
|
$list.filter('[font="' + font + '"]').addClass('active');
|
||||||
|
|
||||||
updateFontSize();
|
updateVars();
|
||||||
updateLineHeight();
|
|
||||||
updateListWidth();
|
|
||||||
adjustLayout();
|
adjustLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
function getVar(name)
|
||||||
|
{
|
||||||
|
var v = $('html').css(name);
|
||||||
|
var m = v.match(/^\s*calc\((.*)\)$/);
|
||||||
|
if (m) v = eval(m[1]);
|
||||||
|
return parseFloat( v );
|
||||||
|
}
|
||||||
|
|
||||||
function getFontSize()
|
function getFontSize()
|
||||||
{
|
{
|
||||||
return parseFloat( $('html').css('--fs') );
|
return getVar('--fs');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLineHeight()
|
function getLineHeight()
|
||||||
{
|
{
|
||||||
return parseFloat( $('html').css('--lh') );
|
return getVar('--lh');;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getListWidth()
|
function getListWidth()
|
||||||
{
|
{
|
||||||
var lw = $('html').css('--lw');
|
return parseInt( getVar('--lw') );
|
||||||
var m = lw.match(/^\s*calc\((.*)\)$/);
|
|
||||||
if (m) lw = eval(m[1]);
|
|
||||||
console.log('getListWidth -> ', lw)
|
|
||||||
return parseInt( lw );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3322,13 +3322,20 @@ console.log('getListWidth -> ', lw)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateVars()
|
||||||
|
{
|
||||||
|
updateFontSize();
|
||||||
|
updateLineHeight();
|
||||||
|
updateListWidth();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
function setFontSize(fs)
|
function setFontSize(fs)
|
||||||
{
|
{
|
||||||
if (9 <= fs && fs <= 24)
|
if (9 <= fs && fs <= 24)
|
||||||
{
|
{
|
||||||
$('html').css('--fs', fs + '').addClass('fs-set');
|
$('html').css('--fs', fs + '').addClass('fs-set');
|
||||||
updateFontSize();
|
updateVars();
|
||||||
adjustLayout();
|
adjustLayout();
|
||||||
|
|
||||||
if (getLineHeight() < fs)
|
if (getLineHeight() < fs)
|
||||||
@@ -3339,11 +3346,13 @@ console.log('getListWidth -> ', lw)
|
|||||||
|
|
||||||
function setLineHeight(lh)
|
function setLineHeight(lh)
|
||||||
{
|
{
|
||||||
|
lh = parseInt(10*lh) / 10.; // trim to a single decimal digit
|
||||||
|
|
||||||
var fs = getFontSize();
|
var fs = getFontSize();
|
||||||
if (fs <= lh && lh <= 3*fs)
|
if (fs <= lh && lh <= 3*fs)
|
||||||
{
|
{
|
||||||
$('html').css('--lh', lh + '').addClass('lh-set');
|
$('html').css('--lh', lh + '').addClass('lh-set');
|
||||||
updateLineHeight();
|
updateVars();
|
||||||
adjustLayout();
|
adjustLayout();
|
||||||
}
|
}
|
||||||
return getLineHeight();
|
return getLineHeight();
|
||||||
@@ -3354,8 +3363,8 @@ console.log('getListWidth -> ', lw)
|
|||||||
if (200 <= lw && lw <= 400)
|
if (200 <= lw && lw <= 400)
|
||||||
{
|
{
|
||||||
$('html').css('--lw', lw + '').addClass('lw-set');
|
$('html').css('--lw', lw + '').addClass('lw-set');
|
||||||
|
updateVars();
|
||||||
adjustLayout();
|
adjustLayout();
|
||||||
updateListWidth();
|
|
||||||
}
|
}
|
||||||
return getListWidth();
|
return getListWidth();
|
||||||
}
|
}
|
||||||
@@ -3712,7 +3721,7 @@ console.log('getListWidth -> ', lw)
|
|||||||
|
|
||||||
//
|
//
|
||||||
$('.config .f-prefs .ui-lh .less').on('click', function(){
|
$('.config .f-prefs .ui-lh .less').on('click', function(){
|
||||||
var lh = setLineHeight( getLineHeight() - 0.5 );
|
var lh = setLineHeight( getLineHeight() - 0.1 );
|
||||||
NB.storage.setLineHeight(lh);
|
NB.storage.setLineHeight(lh);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -3726,7 +3735,7 @@ console.log('getListWidth -> ', lw)
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.config .f-prefs .ui-lh .more').on('click', function(){
|
$('.config .f-prefs .ui-lh .more').on('click', function(){
|
||||||
var lh = setLineHeight( getLineHeight() + 0.5 );
|
var lh = setLineHeight( getLineHeight() + 0.1 );
|
||||||
NB.storage.setLineHeight(lh);
|
NB.storage.setLineHeight(lh);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user