Skip to content

Commit

Permalink
Update styles.ts: add support to top,left,bottom and right
Browse files Browse the repository at this point in the history
This add support for absolute positionning with top,left,bottom and right
  • Loading branch information
YPetremann authored Jan 23, 2025
1 parent 57a4b21 commit c90810a
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,24 @@ export type Styles = {
readonly overflowY?: 'visible' | 'hidden';
};

const applyPositionStyles = (node: YogaNode, style: Styles): void => {
if ('position' in style) {
node.setPositionType(
style.position === 'absolute'
? Yoga.POSITION_TYPE_ABSOLUTE
: Yoga.POSITION_TYPE_RELATIVE,
);
}
const applyPositionStyles = (node, style) => {

Check failure on line 307 in src/styles.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Parameter 'node' implicitly has an 'any' type.

Check failure on line 307 in src/styles.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Parameter 'style' implicitly has an 'any' type.

Check failure on line 307 in src/styles.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Parameter 'node' implicitly has an 'any' type.

Check failure on line 307 in src/styles.ts

View workflow job for this annotation

GitHub Actions / Node.js 20

Parameter 'style' implicitly has an 'any' type.
if ('position' in style) {
node.setPositionType(style.position === 'absolute'
? Yoga.POSITION_TYPE_ABSOLUTE
: Yoga.POSITION_TYPE_RELATIVE);
}
if ('top' in style) {
node.setPosition(Yoga.EDGE_TOP, style.top ?? 0);
}
if ('left' in style) {
node.setPosition(Yoga.EDGE_LEFT, style.left ?? 0);
}
if ('bottom' in style) {
node.setPosition(Yoga.EDGE_BOTTOM, style.bottom ?? 0);
}
if ('right' in style) {
node.setPosition(Yoga.EDGE_RIGHT, style.right ?? 0);
}
};

const applyMarginStyles = (node: YogaNode, style: Styles): void => {
Expand Down

0 comments on commit c90810a

Please sign in to comment.