Skip to content

Commit

Permalink
fix: sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Dec 18, 2021
1 parent 6d4b61b commit 896a379
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/box-sizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class BoxSizingStyle extends Style {
static override prefixes = /^box:(content|border)/;
static override properties = [BOX + DASH + SIZING];
static override values = {
[CONTENT]: CONTENT + DASH + BOX,
[BORDER]: BORDER + DASH + BOX
content: CONTENT + DASH + BOX,
border: BORDER + DASH + BOX
}
}
8 changes: 7 additions & 1 deletion src/constants/css-property-keyword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,10 @@ export const LAYOUT = 'layout';
export const ACCENT = 'accent';
export const CARET = 'caret';
export const SNAP = 'snap';
export const STOP = 'stop';
export const STOP = 'stop';
export const SIZING_VALUES = {
full: PERCENT100,
fit: FIT_CONTENT,
max: MAX_CONTENT,
min: MIN_CONTENT
}
4 changes: 2 additions & 2 deletions src/flex-basis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BASIS, DASH, FLEX, FULL, PERCENT100 } from './constants/css-property-keyword';
import { BASIS, DASH, FLEX, SIZING_VALUES } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class FlexBasisStyle extends Style {
static override properties = [FLEX + DASH + BASIS];
static override values = { [FULL]: PERCENT100 };
static override values = SIZING_VALUES;
}
4 changes: 2 additions & 2 deletions src/flex-direction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class FlexDirectionStyle extends Style {
static override prefixes = /^flex:((row|col|column)(-reverse)?)/;
static override properties = [FLEX + DASH + DIRECTION];
static override values = {
[COL]: COLUMN,
[COL + DASH + REVERSE]: COLUMN + DASH + REVERSE
col: COLUMN,
'col-reverse': COLUMN + DASH + REVERSE
};
}
6 changes: 3 additions & 3 deletions src/font-family.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export class FontFamilyStyle extends Style {
static override supportFullName = false;
static override properties = [FONT + DASH + FAMILY];
static override values = {
[MONO]: VAR_F + MONO + VAR_END,
[SANS]: VAR_F + SANS + VAR_END,
[SERIF]: VAR_F + SERIF + VAR_END
mono: VAR_F + MONO + VAR_END,
sans: VAR_F + SANS + VAR_END,
serif: VAR_F + SERIF + VAR_END
}
static override semantics = {};
}
Expand Down
33 changes: 12 additions & 21 deletions src/font-weight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@ import { DASH, FONT, FONT_PREFIX, F_PREFIX, WEIGHT } from './constants/css-prope
import { Style } from '@master/style';

export class FontWeightStyle extends Style {
static override prefixes = /^f(ont)?-weight:/;
static override prefixes = /^f(ont)?-weight:|f(ont):(thin|extralight|light|regular|medium|semibold|bold|extrabold|heavy)/;
static override properties = [FONT + DASH + WEIGHT];
static override supportFullName = false;
static override unit = '';
static override values = {};
static override semantics = {};
}

let weight = 100;
for (const name of [
'thin',
'extralight',
'light',
'regular',
'medium',
'semibold',
'bold',
'extrabold',
'heavy'
]) {
FontWeightStyle.values[name] = weight;
FontWeightStyle.semantics[F_PREFIX + name] = weight;
FontWeightStyle.semantics[FONT_PREFIX + name] = weight;
weight += 100;
static override values = {
thin: 100,
extralight: 200,
light: 300,
regular: 400,
medium: 500,
semibold: 600,
bold: 700,
extrabold: 800,
heavy: 900
};
}
10 changes: 3 additions & 7 deletions src/height.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { FIT, FIT_CONTENT, FULL, HEIGHT, H_PREFIX, MAX, MAX_CONTENT, MIN, MIN_CONTENT, PERCENT100 } from './constants/css-property-keyword';
import { HEIGHT, SIZING_VALUES } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class HeightStyle extends Style {
static override prefixes = /^h:/;
static override properties = [HEIGHT];
static override values = {
[FULL]: PERCENT100,
[FIT]: FIT_CONTENT,
[MAX]: MAX_CONTENT,
[MIN]: MIN_CONTENT
}
static override values = SIZING_VALUES;

}
10 changes: 5 additions & 5 deletions src/max-height.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { FIT, FIT_CONTENT, FULL, MAX, MAX_CONTENT, MAX_HEIGHT, MIN, MIN_CONTENT, PERCENT100 } from './constants/css-property-keyword';
import { FIT_CONTENT, MAX_CONTENT, MAX_HEIGHT, MIN_CONTENT, PERCENT100 } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class MaxHeightStyle extends Style {
static override prefixes = /^max-h(eight)?:/;
static override properties = [MAX_HEIGHT];
static override supportFullName = false;
static override values = {
[FULL]: PERCENT100,
[FIT]: FIT_CONTENT,
[MAX]: MAX_CONTENT,
[MIN]: MIN_CONTENT
full: PERCENT100,
fit: FIT_CONTENT,
max: MAX_CONTENT,
min: MIN_CONTENT
}
}
11 changes: 3 additions & 8 deletions src/max-width.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { FIT, FIT_CONTENT, FULL, MAX, MAX_CONTENT, MAX_WIDTH, MIN, MIN_CONTENT, PERCENT100, W_PREFIX } from './constants/css-property-keyword';
import { MAX_WIDTH, SIZING_VALUES } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class MaxWidthStyle extends Style {
static override prefixes = /^max-w(idth)?:/;
static override prefixes = /^max-w(idth)?:/;
static override properties = [MAX_WIDTH];
static override supportFullName = false;
static override values = {
[FULL]: PERCENT100,
[FIT]: FIT_CONTENT,
[MAX]: MAX_CONTENT,
[MIN]: MIN_CONTENT
}
static override values = SIZING_VALUES;
}
12 changes: 6 additions & 6 deletions src/min-height.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { DASH, FIT, FIT_CONTENT, FULL, H_PREFIX, MAX, MAX_CONTENT, MIN, MIN_CONTENT, MIN_HEIGHT, PERCENT100 } from './constants/css-property-keyword';
import { DASH, FIT_CONTENT, H_PREFIX, MAX_CONTENT, MIN, MIN_CONTENT, MIN_HEIGHT, PERCENT100 } from './constants/css-property-keyword';
import { Style } from '@master/style';

const MIN_HEIGHT_PREFIX = MIN + DASH + H_PREFIX;

export class MinHeightStyle extends Style {
static override prefixes = /^min-h(eight)?:/;
static override prefixes = /^min-h(eight)?:/;
static override properties = [MIN_HEIGHT];
static override supportFullName = false;
static override values = {
[FULL]: PERCENT100,
[FIT]: FIT_CONTENT,
[MAX]: MAX_CONTENT,
[MIN]: MIN_CONTENT
full: PERCENT100,
fit: FIT_CONTENT,
max: MAX_CONTENT,
min: MIN_CONTENT
}
}
11 changes: 3 additions & 8 deletions src/min-width.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { DASH, FIT, FIT_CONTENT, FULL, MAX, MAX_CONTENT, MIN, MIN_CONTENT, MIN_WIDTH, PERCENT100, W_PREFIX } from './constants/css-property-keyword';
import { DASH, MIN, MIN_WIDTH, SIZING_VALUES, W_PREFIX } from './constants/css-property-keyword';
import { Style } from '@master/style';

const MIN_W_PREFIX = MIN + DASH + W_PREFIX;

export class MinWidthStyle extends Style {
static override prefixes = /^min-w(idth)?:/;
static override prefixes = /^min-w(idth)?:/;
static override properties = [MIN_WIDTH];
static override supportFullName = false;
static override values = {
[FULL]: PERCENT100,
[FIT]: FIT_CONTENT,
[MAX]: MAX_CONTENT,
[MIN]: MIN_CONTENT
}
static override values = SIZING_VALUES;
}
2 changes: 1 addition & 1 deletion src/overflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DASH, OVERFLOW, X, Y } from './constants/css-property-keyword';
import { X, Y } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class OverflowStyle extends Style {
Expand Down
26 changes: 11 additions & 15 deletions src/position.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { ABS, ABSOLUTE, FIXED, POSITION, REL, RELATIVE, STATIC, STICKY } from './constants/css-property-keyword';
import { ABSOLUTE, POSITION, RELATIVE } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class PositionStyle extends Style {
static override properties = [POSITION];
static override values = {
[ABS]: ABSOLUTE,
[REL]: RELATIVE
'abs': ABSOLUTE,
'rel': RELATIVE
};
}

PositionStyle.semantics = {};
for (const value of [
STATIC,
FIXED,
ABS,
REL,
STICKY
]) {
PositionStyle.semantics[value] = value;
}
static semantics = {
static: 'static',
fixed: 'fixed',
abs: 'absolute',
rel: 'relative',
sticky: 'sticky'
};
}
11 changes: 3 additions & 8 deletions src/width.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { FIT, FIT_CONTENT, FULL, MAX, MAX_CONTENT, MIN, MIN_CONTENT, PERCENT100, WIDTH } from './constants/css-property-keyword';
import { SIZING_VALUES, WIDTH } from './constants/css-property-keyword';
import { Style } from '@master/style';

export class WidthStyle extends Style {
static override prefixes = /^w:/;
static override prefixes = /^w:/;
static override properties = [WIDTH];
static override values = {
[FULL]: PERCENT100,
[FIT]: FIT_CONTENT,
[MAX]: MAX_CONTENT,
[MIN]: MIN_CONTENT
}
static override values = SIZING_VALUES;
}

0 comments on commit 896a379

Please sign in to comment.