Skip to content

Commit

Permalink
Merge pull request #191 from numldesign/v1.1.2
Browse files Browse the repository at this point in the history
v1.1.2
  • Loading branch information
tenphi authored May 27, 2021
2 parents bde796c + 11c4e03 commit 7642e70
Show file tree
Hide file tree
Showing 22 changed files with 6,052 additions and 12,040 deletions.
4 changes: 4 additions & 0 deletions components/playground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@
</nu-code>

<nu-code value={codeExample}></nu-code>

<nu-block>
This is something <nu-cd><pre>var a = '123';</pre></nu-cd>. This is something <nu-cd><pre>var a = '123';</pre></nu-cd>. This is something <nu-cd><pre>var a = '123';</pre></nu-cd>. This is something <nu-cd><pre>var a = '123';</pre></nu-cd>.
</nu-block>
</nu-card>
{/if}

Expand Down
2 changes: 2 additions & 0 deletions lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
queries:
- exclude: js/mixed-static-instance-this-access
18,016 changes: 6,015 additions & 12,001 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/behaviors/appear.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ function onPositionChange() {
['scroll', 'resize', 'wheel', 'touchmove', 'tap'].forEach(eventName => {
window.addEventListener(eventName, onPositionChange, { passive: true });
});

// lgtm [js/mixed-static-instance-this-access]
2 changes: 0 additions & 2 deletions src/behaviors/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,3 @@ export default class ComponentBehavior extends WidgetBehavior {
this.set({ value });
}
}

// lgtm [js/mixed-static-instance-this-access]
2 changes: 0 additions & 2 deletions src/behaviors/fileinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,3 @@ export default class FileInputBehavior extends WidgetBehavior {
return value;
}
}

// lgtm [js/mixed-static-instance-this-access]
2 changes: 0 additions & 2 deletions src/behaviors/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,3 @@ export default class FocusBehavior extends Behavior {
this.host.nuSetMod('focusable', param || null);
}
}

// lgtm [js/mixed-static-instance-this-access]
2 changes: 0 additions & 2 deletions src/behaviors/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,3 @@ export default class InputBehavior extends WidgetBehavior {
}
}
}

// lgtm [js/mixed-static-instance-this-access]
2 changes: 0 additions & 2 deletions src/behaviors/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,5 +654,3 @@ export default class WidgetBehavior extends Behavior {
this.emit('log', args);
}
}

// lgtm [js/mixed-static-instance-this-access]
2 changes: 1 addition & 1 deletion src/converters/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TOKEN_RES = [
[COM, /(\/\/|#).*?(?=\n|$)/],
[COM, /\/\*[\s\S]*?\*\//],
[COM, /<!--[\s\S]*?-->/],
[REX, /\/(\\\/|[^\n])*?\/(?=[^\w])/],
[REX, /\/(\\\/|[^\n])*?\/(?=[^\w])/], // lgtm [js/redos]
[STR, /(['"])(\\\1|[\s\S])*?\1/],
[NUM, /[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?/],
[SPC, /\s+/],
Expand Down
2 changes: 0 additions & 2 deletions src/definitions/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,3 @@ export default class NuAttrs extends NuDefinition {
parent.nuVerifyChildren({ attrs: selector, shadow });
}
}

// lgtm [js/mixed-static-instance-this-access]
2 changes: 0 additions & 2 deletions src/definitions/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,3 @@ export default class NuBase extends NuDefinition {
log('set base:', { value: normalizedValue });
}
}

// lgtm [js/mixed-static-instance-this-access]
5 changes: 4 additions & 1 deletion src/elements/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ export default class NuAbstract extends HTMLElement {
if (name.startsWith('use-')) {
name = name.replace('use-', '');

if (name === 'behaviors') return;

if (behaviors.has(name)) {
this.nuUse(name, value);
}
Expand Down Expand Up @@ -1715,8 +1717,9 @@ export default class NuAbstract extends HTMLElement {
const allBehaviors = this.constructor.nuAllBehaviors;

const attrValue = this.getAttribute(`use-${name}`);
const behavioursAttrValue = this.getAttribute('use-behaviors');

if (isNoValue(attrValue)) return Promise.resolve();
if (isNoValue(attrValue) || isNoValue(behavioursAttrValue)) return Promise.resolve();

let options = `${allBehaviors[name] || ''} ${value || ''}`;

Expand Down
13 changes: 12 additions & 1 deletion src/elements/cd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@ export default class NuCd extends NuCode {
static get nuStyles() {
return {
display: 'inline-block',
padding: '.125rem .25em',
padding: '0 .25em',
fill: 'diff',
};
}

static get nuName() {
return 'cd -code';
}

static nuCSS({ tag, css }) {
return [
...css,

`${tag} {
line-height: calc(var(--line-height) - 1px);
}`,
];
}
}
4 changes: 2 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export function query(element, selector) {

prevElement = element;

element = element.parentNode || element.host
element = element.parentNode || element.host;
} while (element);
}

Expand Down Expand Up @@ -1377,7 +1377,7 @@ export function parseColor(val, ignoreError = false, shortSyntax = false) {
return {
name,
color,
}
};
}

return {
Expand Down
3 changes: 1 addition & 2 deletions src/hsluv.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ function T(a) {

const l = [[3.240969941904521, -1.537383177570093, -.498610760293], [-.96924363628087, 1.87596750150772, .041555057407175], [.055630079696993, -.20397695888897, 1.056971514242878]],
v = [[.41239079926595, .35758433938387, .18048078840183], [.21263900587151, .71516867876775, .072192315360733], [.019330818715591, .11919477979462, .95053215224966]],
B = 1, C = .19783000664283, D = .46831999493879, k = 903.2962962, g = .0088564516,
M = "0123456789abcdef";
B = 1, C = .19783000664283, D = .46831999493879, k = 903.2962962, g = .0088564516;

export const hsluvToRgb = (hsl) => Q(hsl).map(n => n * 255);
export const rgbToHsluv = (rgb) => R(rgb.map(n => n / 255));
Expand Down
4 changes: 2 additions & 2 deletions src/settings.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ROOT, setRootContext } from './context';
import { devMode, isNoValue, isYesValue, requestIdleCallback } from './helpers';
import { devMode, isYesValue, requestIdleCallback } from './helpers';

const DATASET = ROOT.dataset;
const SCHEME_OPTIONS = ['auto', 'light', 'dark'];
const CONTRAST_OPTIONS = ['auto', 'no-preference', 'more'];
const ICONS_OPTIONS = ['feather', 'eva', 'ion', 'no'];
const BEHAVIORS_OPTIONS = ['auto', 'no', 'manual']
const BEHAVIORS_OPTIONS = ['auto', 'no', 'manual'];

export const preventInit = DATASET.nuPrevent != null;
export const behaviorOption = BEHAVIORS_OPTIONS.includes(DATASET.nuBehaviors)
Expand Down
2 changes: 1 addition & 1 deletion src/styles/fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SPECIAL_TEXT_VALUE = 'var(--special-text-color) !important';
export default function fillAttr(val) {
val = convertCustomFuncs(val);

let { color, name, opacity } = parseColor(val);
let { color, name } = parseColor(val);

if (!val || name === 'local') {
return [{
Expand Down
7 changes: 0 additions & 7 deletions src/styles/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ const FLEX_MAP_SECOND = {
'column-reverse': 'margin-left',
};

const INVERT_MAP = {
'margin-top': 'margin-bottom',
'margin-right': 'margin-left',
'margin-bottom': 'margin-top',
'margin-left': 'margin-right',
};

function getLocalProp(dir, invert = false) {
return (invert ^ dir.includes('row')) ? 'var(--local-h-gap)' : 'var(--local-v-gap)';
}
Expand Down
10 changes: 7 additions & 3 deletions src/styles/group-radius.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasNegativeMod, hasPositiveMod, parseAttr } from '../helpers';
import { hasNegativeMod, parseAttr } from '../helpers';

const MAP = {
row: ['* 0 0 *', '0 * * 0'],
Expand Down Expand Up @@ -30,13 +30,17 @@ export default function groupRadiusAttr(val) {
const endValue = MAP[flow][reverse ? 0 : 1].replace(/\*/g, value);

return [{
$suffix: '>:first-child:not([radius])',
$suffix: '>:first-child:not(:last-child):not([radius])',
'border-radius': startValue,
'--local-radius': startValue,
}, {
$suffix: '>:last-child:not([radius])',
$suffix: '>:last-child:not(:first-child):not([radius])',
'border-radius': endValue,
'--local-radius': endValue,
}, {
$suffix: '>:last-child:first-child:not([radius])',
'border-radius': value,
'--local-radius': value,
}, {
$suffix: '>:not(:last-child):not(:first-child):not([radius])',
'border-radius': '0',
Expand Down
1 change: 0 additions & 1 deletion src/styles/snapping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { hasNegativeMod, parseAttr } from '../helpers';
import snapAttr from './snap';
import filter from './filter';

const OPTIONS = ['mandatory', 'proximity'];
const DIRS = ['x', 'y'];
Expand Down
3 changes: 1 addition & 2 deletions src/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ export function generateTheme({ hue, saturation, pastel, type, contrast, lightne
theme['special-mark'] = setOpacity([...theme['special-text']], highContrast ? 0.16 : .08);

const shadowSaturation = saturation * (type === 'main' ? .66 : 1);
const specialShadowSaturation = 100;
const shadowContrastRatio = 1.8 * (highContrast ? 1.5 : 1);
const specialShadowContrastRatio = (type === 'special' || (!darkScheme && type === 'swap') ? 1.5 : 1) * shadowContrastRatio * (darkScheme ? 1.5 : 1);
const shadowLightness = findContrastLightness(theme.bg[2], shadowContrastRatio, true);
Expand Down Expand Up @@ -744,7 +743,7 @@ export function parseHue(val) {

if (!values[0]) {
if (devMode) {
warn('hue(): 1 argument required.')
warn('hue(): 1 argument required.');
}

return;
Expand Down

0 comments on commit 7642e70

Please sign in to comment.