Skip to content

Commit 66026c2

Browse files
authored
Merge pull request #13 from 1Byte-Software/develop
Custom ConfigProvider
2 parents ec793ab + 0d0aed9 commit 66026c2

File tree

29 files changed

+268
-26
lines changed

29 files changed

+268
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "1byte-react-design",
3-
"version": "1.1.24-7",
3+
"version": "1.3.22-15",
44
"main": "dist/index.js",
55
"module": "dist/index.js",
66
"types": "dist/index.d.ts",

src/atomics/Typography/styles.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,30 @@ export const TypographyTitleStyles = styled(Typography.Title, {
2424
}}
2525
`;
2626

27-
export const TypographyTextStyles = styled(Typography.Text)<Pick<RdTypographyTextProps, 'size'>>`
27+
export const TypographyTextStyles = styled(Typography.Text, {
28+
shouldForwardProp: prop =>
29+
getExcludeForwardProps<RdTypographyTextProps>(
30+
['noWrap', 'size'] as (keyof RdTypographyTextProps)[],
31+
prop
32+
),
33+
})<Pick<RdTypographyTextProps, 'size' | 'noWrap'>>`
2834
${({ size }) => {
2935
switch (size) {
3036
case 'small':
3137
return `
3238
font-size: ${getComponentOrGlobalToken('Typography', 'fontSizeSM')}px;
3339
`;
34-
// Case normal is the default size
3540
}
3641
}}
42+
43+
${({ noWrap }) => {
44+
return (
45+
noWrap &&
46+
css`
47+
text-wrap: nowrap;
48+
`
49+
);
50+
}}
3751
`;
3852

3953
export const TypographyParagraphStyles = styled(Typography.Paragraph, {
@@ -47,7 +61,9 @@ export const TypographyParagraphStyles = styled(Typography.Paragraph, {
4761
return (
4862
minRows &&
4963
css`
50-
min-height: ${Number(getComponentOrGlobalToken('Typography', 'lineHeight')) * Number(getComponentOrGlobalToken('Typography', 'fontSize')) * minRows}px;
64+
min-height: ${Number(getComponentOrGlobalToken('Typography', 'lineHeight')) *
65+
Number(getComponentOrGlobalToken('Typography', 'fontSize')) *
66+
minRows}px;
5167
`
5268
);
5369
}}

src/atomics/Typography/types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ type TypographyParagraphPropsExtend = TypographyBaseProps & {
2727
};
2828
type TypographyTextPropsExtend = TypographyBaseProps & {
2929
/**
30-
* @description The size of the text.
30+
* If true, the text will not wrap to the next line and instead will be truncated with an ellipsis when it overflows.
31+
* This is useful when you want to keep the text in a single line.
32+
* @default false
33+
*/
34+
noWrap?: boolean;
35+
36+
/**
37+
* The size of the text.
3138
* @default "normal"
3239
*/
3340
size?: 'small' | 'normal';
3441

3542
/**
36-
* @description Callback function that is triggered when the text value changes.
43+
* Callback function that is triggered when the text value changes.
3744
* @param value The new value of the text.
3845
*/
3946
onChange?: (value: string) => void;
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
import styled from '@emotion/styled';
22
import { ColorPicker } from 'antd';
3+
import { getExcludeForwardProps } from '../../utils';
4+
import { RdColorPickerProps } from './types';
35

4-
export const ColorPickerStyles = styled(ColorPicker)``;
6+
export const ColorPickerStyles = styled(ColorPicker, {
7+
shouldForwardProp: prop =>
8+
getExcludeForwardProps<RdColorPickerProps>(
9+
['readonly'] as (keyof RdColorPickerProps)[],
10+
prop
11+
),
12+
})<RdColorPickerProps>`
13+
${({ readonly }) => {
14+
return (
15+
readonly &&
16+
`
17+
pointer-events: none;
18+
`
19+
);
20+
}}
21+
`;

src/molecules/ColorPicker/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ type ColorPickerComponentTokenExtend = {};
1010
//#endregion
1111

1212
//#region Define extended types
13-
type ColorPickerPropsExtend = {};
13+
type ColorPickerPropsExtend = {
14+
/**
15+
* Determines whether the color picker should be in a read-only state.
16+
* When set to `true`, user interactions such as selecting or changing colors are disabled.
17+
*
18+
* @default false
19+
*/
20+
readonly?: boolean;
21+
};
1422
//#endregion
1523

1624
//#region Export types

src/molecules/Divider/Divider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import { DividerStyles } from './styles';
22
import { RdDividerComponent } from './types';
33

44
export const Divider: RdDividerComponent = props => {
5-
return <DividerStyles {...props} />;
5+
const { disableMargin = false, ...antdProps } = props;
6+
return <DividerStyles disableMargin={disableMargin} {...antdProps} />;
67
};

src/molecules/Divider/styles.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
import styled from '@emotion/styled';
22
import { Divider } from 'antd';
3+
import { getExcludeForwardProps } from '../../utils';
4+
import { RdDividerProps } from './types';
5+
import { css } from '@emotion/react';
36

4-
export const DividerStyles = styled(Divider)``;
7+
export const DividerStyles = styled(Divider, {
8+
shouldForwardProp: prop =>
9+
getExcludeForwardProps<RdDividerProps>(['disableMargin'] as (keyof RdDividerProps)[], prop),
10+
})<RdDividerProps>`
11+
${({ disableMargin }) => {
12+
return disableMargin && css`
13+
margin: 0;
14+
`;
15+
}}
16+
`;

src/molecules/Divider/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ type DividerComponentTokenExtend = {};
1010
//#endregion
1111

1212
//#region Define extended types
13-
type DividerPropsExtend = {};
13+
type DividerPropsExtend = {
14+
/**
15+
* If `true`, removes the default margin of the Divider.
16+
* @default false.
17+
*/
18+
disableMargin?: boolean;
19+
};
1420
//#endregion
1521

1622
//#region Export types
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import { useContext } from 'react';
2+
import { ConfigProvider } from '../../organisms';
13
import { PaginationStyled } from './styles';
24
import { RdPaginationComponent } from './types';
35

46
export const Pagination: RdPaginationComponent = props => {
5-
return <PaginationStyled {...props} />;
7+
const { pagination: defaultPaginationProps } = useContext(ConfigProvider.ConfigContext);
8+
const { pageSizeOptions } = defaultPaginationProps || {};
9+
10+
return <PaginationStyled pageSizeOptions={pageSizeOptions} {...props} />;
611
};

src/molecules/Select/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
export * from './strategies';
12
export * from './Select';
23
export * from './types';

0 commit comments

Comments
 (0)