Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit cd5e49b

Browse files
committed
chore: adds positioning move examples
1 parent 7277d0a commit cd5e49b

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

packages/yubaba-common/src/createMoveExamples/index.tsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,72 @@ export const createMoveExamples = (options: { useDistinctEnd: boolean; namePrefi
3939
</Common.Toggler>
4040
),
4141

42+
WithAbsolutePositioning: () => (
43+
<Common.Toggler>
44+
{({ shown, toggle }) => (
45+
<div>
46+
<Styled.Padding />
47+
{!shown ? (
48+
<Baba name={`${options.namePrefix}-anim`} key={`${options.namePrefix}-1`}>
49+
<Animation>
50+
{({ ref, ...props }) => (
51+
<Styled.RelativeListItem innerRef={ref} onClick={() => toggle()} {...props} />
52+
)}
53+
</Animation>
54+
</Baba>
55+
) : (
56+
<Baba name={`${options.namePrefix}-anim`} key={`${options.namePrefix}-2`}>
57+
<Animation>
58+
{({ ref, ...props }) => (
59+
<Styled.AbsoluteListItem
60+
innerRef={ref}
61+
onClick={() => toggle()}
62+
alternate={options.useDistinctEnd}
63+
{...props}
64+
/>
65+
)}
66+
</Animation>
67+
</Baba>
68+
)}
69+
<Styled.Padding />
70+
</div>
71+
)}
72+
</Common.Toggler>
73+
),
74+
75+
WithFixedPositioning: () => (
76+
<Common.Toggler>
77+
{({ shown, toggle }) => (
78+
<div>
79+
<Styled.Padding />
80+
{!shown ? (
81+
<Baba name={`${options.namePrefix}-anim`} key={`${options.namePrefix}-1`}>
82+
<Animation>
83+
{({ ref, ...props }) => (
84+
<Styled.RelativeListItem innerRef={ref} onClick={() => toggle()} {...props} />
85+
)}
86+
</Animation>
87+
</Baba>
88+
) : (
89+
<Baba name={`${options.namePrefix}-anim`} key={`${options.namePrefix}-2`}>
90+
<Animation>
91+
{({ ref, ...props }) => (
92+
<Styled.FixedListItem
93+
innerRef={ref}
94+
onClick={() => toggle()}
95+
alternate={options.useDistinctEnd}
96+
{...props}
97+
/>
98+
)}
99+
</Animation>
100+
</Baba>
101+
)}
102+
<Styled.Padding />
103+
</div>
104+
)}
105+
</Common.Toggler>
106+
),
107+
42108
WithMargin: () => (
43109
<Common.Toggler>
44110
{({ shown, toggle }) => (

packages/yubaba-common/src/createMoveExamples/styled.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ export const ListItem = styled.button<ListItemProps>`
6161
: ''};
6262
`;
6363

64+
export const RelativeListItem = styled(ListItem)`
65+
position: relative;
66+
`;
67+
68+
export const AbsoluteListItem = styled(ListItem)`
69+
position: absolute;
70+
bottom: 0;
71+
`;
72+
73+
export const FixedListItem = styled(ListItem)`
74+
position: fixed;
75+
bottom: 0;
76+
`;
77+
6478
export const ListItemContainer = styled.div`
6579
display: flex;
6680
align-items: center;

0 commit comments

Comments
 (0)