Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boxsizing to playground #1724

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions website/src/components/FlexStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import {
Align,
BoxSizing,
Direction,
Display,
Edge,
Expand Down Expand Up @@ -60,6 +61,7 @@ export type FlexStyle = {
borderInlineWidth?: number;
borderBlockWidth?: number;
bottom?: number | `${number}%`;
boxSizing?: 'border-box' | 'content-box';
direction?: 'ltr' | 'rtl';
display?: 'none' | 'flex';
end?: number | `${number}%`;
Expand Down Expand Up @@ -154,6 +156,9 @@ export function applyStyle(node: YogaNode, style: FlexStyle = {}): void {
case 'bottom':
node.setPosition(Edge.Bottom, style.bottom);
break;
case 'boxSizing':
node.setBoxSizing(boxSizing(style.boxSizing));
break;
case 'direction':
node.setDirection(direction(style.direction));
break;
Expand Down Expand Up @@ -335,6 +340,16 @@ function alignItems(str?: AlignItems): Align {
throw new Error(`"${str}" is not a valid value for alignItems`);
}

function boxSizing(str?: 'border-box' | 'content-box'): BoxSizing {
switch (str) {
case 'border-box':
return BoxSizing.BorderBox;
case 'content-box':
return BoxSizing.ContentBox;
}
throw new Error(`"${str}" is not a valid value for boxSizing`);
}

function direction(str?: 'ltr' | 'rtl'): Direction {
switch (str) {
case 'ltr':
Expand Down
Loading