Skip to content

Commit

Permalink
support arbitrary grow-[x] (issue 146)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredh159 committed Mar 22, 2024
1 parent b935eea commit a368561
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/__tests__/flex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe(`flex grow/shrink`, () => {
[`grow`, { flexGrow: 1 }],
[`grow-0`, { flexGrow: 0 }],
[`grow-33`, { flexGrow: 33 }],
[`grow-[33]`, { flexGrow: 33 }],
[`shrink`, { flexShrink: 1 }],
[`shrink-0`, { flexShrink: 0 }],
[`shrink-77`, { flexShrink: 77 }],
Expand Down
3 changes: 3 additions & 0 deletions src/resolve/flex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export function flexGrowShrink(
config?: TwTheme['flexGrow'] | TwTheme['flexShrink'],
): StyleIR | null {
value = value.replace(/^-/, ``);
if (value[0] === `[` && value.endsWith(`]`)) {
value = value.slice(1, -1);
}
const configKey = value === `` ? `DEFAULT` : value;
const numericValue = Number(config?.[configKey] ?? value);
if (!Number.isNaN(numericValue)) {
Expand Down

0 comments on commit a368561

Please sign in to comment.