Skip to content

Commit

Permalink
fix: border
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSeage committed Dec 24, 2021
1 parent 877043d commit 81d0281
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/border.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
import { Style } from '@master/style';
import { BORDER } from './constants/css-property-keyword';
import { BORDER, DASH } from './constants/css-property-keyword';
import { B, BOTTOM, L, LEFT, R, RIGHT, T, TOP, X, Y } from './constants/direction';

export class BorderStyle extends Style {
static override prefixes = /^b:/;
static override key = BORDER;
static override prefixes = /^b((x|y|t|b|l|r)?|(order)?(-(left|right|top|bottom))?):/;
override get props(): { [key: string]: any } {
const direction = /^b(order)?-?(.)?/.exec(this.prefix)[2];
const BORDER_LEFT = BORDER + DASH + LEFT;
const BORDER_RIGHT = BORDER + DASH + RIGHT;
const BORDER_TOP = BORDER + DASH + TOP;
const BORDER_BOTTOM = BORDER + DASH + BOTTOM;
switch (direction) {
case X:
return {
[BORDER_LEFT]: this,
[BORDER_RIGHT]: this
}
case Y:
return {
[BORDER_TOP]: this,
[BORDER_BOTTOM]: this
}
case L:
return {
[BORDER_LEFT]: this
}
case R:
return {
[BORDER_RIGHT]: this
}
case T:
return {
[BORDER_TOP]: this
}
case B:
return {
[BORDER_BOTTOM]: this
}
default:
return {
[BORDER]: this
}
}
}
}

0 comments on commit 81d0281

Please sign in to comment.