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

Commit 1f38438

Browse files
committed
✨ feat: 新增 horizontal props
1 parent 9f68cb8 commit 1f38438

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

packages/layout-kit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"registry": "https://registry.npmjs.org",
1414
"access": "public"
1515
},
16-
"peerDependencies": {
17-
"styled-components": ">5"
16+
"dependencies": {
17+
"styled-components": "^5.3.3"
1818
},
1919
"devDependencies": {
2020
"styled-components": "^5.3.3",

packages/layout-kit/src/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
export type CommonSpaceNumber = 2 | 4 | 8 | 12 | 16 | 24;
1212

1313
export interface IFlexbox {
14+
horizontal?: boolean;
1415
direction?: FlexDirection;
1516
distribution?: ContentDistribution;
1617
align?: ContentPosition;
@@ -28,7 +29,7 @@ export const Flexbox: FC<FlexboxProps> = styled.div.attrs(() => ({
2829
}))<IFlexbox>`
2930
display: flex;
3031
flex-direction: ${(props) => {
31-
return getFlexDirection(props.direction);
32+
return getFlexDirection(props.direction, props.horizontal);
3233
}};
3334
justify-content: ${(props) => props.distribution};
3435
align-items: ${(props) => props.align};
@@ -40,8 +41,10 @@ export const Flexbox: FC<FlexboxProps> = styled.div.attrs(() => ({
4041
4142
> *:not(:last-child) {
4243
margin-right: ${(props) =>
43-
getFlexDirection(props.direction) === 'row' && calcValue(props.gap)};
44+
getFlexDirection(props.direction, props.horizontal) === 'row' &&
45+
calcValue(props.gap)};
4446
margin-bottom: ${(props) =>
45-
getFlexDirection(props.direction) === 'column' && calcValue(props.gap)};
47+
getFlexDirection(props.direction, props.horizontal) === 'column' &&
48+
calcValue(props.gap)};
4649
}
4750
`;

packages/layout-kit/src/type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export type ContentPosition =
44
| 'flex-end'
55
| 'flex-start'
66
| 'start'
7-
| 'stretch';
7+
| 'stretch'
8+
| 'baseline';
89

910
export type ContentDistribution =
1011
| 'center'

packages/layout-kit/src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { FlexDirection } from './type';
22

3-
export const getFlexDirection = (direction: FlexDirection) => {
3+
export const getFlexDirection = (
4+
direction: FlexDirection,
5+
isHorizontal: boolean,
6+
) => {
7+
if (isHorizontal) return 'row';
8+
49
switch (direction) {
510
case 'horizontal':
611
return 'row';

0 commit comments

Comments
 (0)