Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
feb81d4
build: change version number
May 22, 2025
1b02ea4
fix: remove unused code
May 31, 2025
b8e2706
feature: add default prop for TextArea
May 31, 2025
d44a93d
feature: add rootClassName for Upload molecule
May 31, 2025
f66dfee
build: change test script, now not need build to test
May 31, 2025
c22af3c
v1.4.30-1
May 31, 2025
fa7e7b8
v1.5.11-1
Jun 12, 2025
514b6e6
fix: Fix Card Grid and Card Meta component
Jun 20, 2025
1425026
feature: Add getDefaultToken for Button
Jun 24, 2025
a4ee6c8
fix: Fix label for DashboardTemplate
Jun 24, 2025
2022111
fix: remove selectFilterOptionByLabel strategy
Jun 27, 2025
a3cd1a5
feature: allow hidden Header, Sidebar, Footer in DashboardTemplate fe…
Jul 2, 2025
f55a3df
fix: remove select strategy in export barrel
Jul 2, 2025
ae67d5d
feature: add RdTreeDataNode type for Tree component
Jul 4, 2025
38220b1
feature: add Result molecule
Jul 18, 2025
ca24cf0
fix: remove not used code
Jul 18, 2025
b2e0049
fix: fix hide pagination with default if pagination is false
Jul 18, 2025
5c2c312
refactor: refactor code Typography
Jul 18, 2025
3c64bb2
fix: fix export berrel
Jul 18, 2025
21ddb41
feature: support render props as children for Form.ItemControl component
Jul 23, 2025
0360a36
refactor: change getComponentOrGlobalToken to getAliasToken and remov…
Jul 30, 2025
578adba
refactor: change getComponentOrGlobalToken to getAliasToken for Typog…
Jul 30, 2025
e4b8e94
refactor: add comment for rdPrepareComponentToken for Button molecule
Jul 30, 2025
248b7b3
feature: add detect height for skeleton loading
Jul 30, 2025
bd045b2
fix: fix unnecessary rerender for Table
Jul 31, 2025
fa5870b
fix: fix import barrel file
Aug 7, 2025
3249b0c
feature: Add SplitScreen template
Aug 7, 2025
bf095e5
feature: Detect Typography.Link Skeleton height during loading
Aug 7, 2025
545e810
fix: remove responseType prop in Switch molecule
Aug 8, 2025
be5ab07
fix: Fix coumponded Upload component
Sep 7, 2025
e890bd3
build: update version 1.6.1
Sep 7, 2025
0f8d755
build: update package.json
Sep 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.6.1]

### Added

- Add getAliasToken helper function.
- Add SplitScreen template.

### Changed

-

### Fixed

- Fix unnecessary rerender for Table.
- Fix UploadDragger to Upload.Dragger

### Deprecated

- Deprecate getComponentOrGlobalToken helper function.

### Removed

- Remove secondary, tertiary, quaternary color.
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"name": "1byte-react-design",
"version": "1.5.0",
"version": "1.6.1",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"scripts": {
"build": "webpack --config webpack.config.js",
"test": "webpack --config webpack.config.js && yalc publish --push --no-scripts"
"test": "yalc publish --push --no-scripts --files ."
},
"files": [
"dist"
],
"dependencies": {
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/modifiers": "^9.0.0",
Expand Down
27 changes: 27 additions & 0 deletions src/atomics/Typography/TypographyLink.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getAliasToken, RdAliasToken } from '../..';
import { RdTypographyTextProps } from './types';

/**
* Calculates the height in pixels of a Typography `Link` component
* using the corresponding `fontSize` and `lineHeight`
* token values from the design token system.
*
* @returns The calculated height in pixels (`fontSize * lineHeight`).
*
* @example
* ```ts
* const height = getHeight();
* console.log(height); // e.g. 18 (depends on token values)
* ```
*/
export const getHeight = () => {
const detectedFontSize = getAliasToken('Typography', 'fontSize') as RdAliasToken['fontSize'];
const detectedLineHeight = getAliasToken(
'Typography',
'lineHeight'
) as RdAliasToken['lineHeight'];

const detectedHeight = detectedFontSize * detectedLineHeight;

return detectedHeight;
};
14 changes: 12 additions & 2 deletions src/atomics/Typography/TypographyLink.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { forwardRef } from 'react';
import { Skeleton } from '../../molecules';
import { TypographyLinkStyles } from './styles';
import { RdTypographyLinkProps } from './types';
import { Skeleton } from '../../molecules';
import { getHeight } from './TypographyLink.helper';

export const TypographyLink = forwardRef(
(props: RdTypographyLinkProps, ref: RdTypographyLinkProps['ref']) => {
const { loading, ...antdProps } = props;

if (loading) return <Skeleton active />;
if (loading) {
return (
<Skeleton.Input
active
style={{
height: getHeight(),
}}
/>
);
}

return <TypographyLinkStyles ref={ref} {...antdProps} />;
}
Expand Down
59 changes: 59 additions & 0 deletions src/atomics/Typography/TypographyText.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { RdAliasToken } from '../../organisms';
import { getAliasToken } from '../../utils';
import { RdTypographyTextProps } from './types';

/**
* Calculates the height in pixels of a Typography `Text` component
* based on its `size` prop, using the corresponding `fontSize` and `lineHeight`
* token values from the design token system.
*
* If an unknown size is provided, it will fallback to `'normal'` size
* using the `fontSize` and `lineHeight` tokens.
*
* @param size - The `size` prop of the `Typography.Text` component. Possible values: `'normal'`, `'small'`.
* @returns The calculated height in pixels (`fontSize * lineHeight`).
*
* @example
* ```ts
* const height = detectHeightBySize('small');
* console.log(height); // e.g. 18 (depends on token values)
* ```
*/
export const detectHeightBySize = (size: RdTypographyTextProps['size']) => {
// Detect fontSize and lineHeight based on `size` prop
let detectedFontSize: number | null = null;
let detectedLineHeight: number | null = null;

switch (size) {
case 'normal':
detectedFontSize = getAliasToken('Typography', 'fontSize') as RdAliasToken['fontSize'];
detectedLineHeight = getAliasToken(
'Typography',
'lineHeight'
) as RdAliasToken['lineHeight'];
break;

case 'small':
detectedFontSize = getAliasToken(
'Typography',
'fontSizeSM'
) as RdAliasToken['fontSizeSM'];
detectedLineHeight = getAliasToken(
'Typography',
'lineHeightSM'
) as RdAliasToken['lineHeightSM'];
break;

default:
// fallback to 'normal' size
detectedFontSize = getAliasToken('Typography', 'fontSize') as RdAliasToken['fontSize'];
detectedLineHeight = getAliasToken(
'Typography',
'lineHeight'
) as RdAliasToken['lineHeight'];
}

const detectedHeight = detectedFontSize * detectedLineHeight;

return detectedHeight;
};
14 changes: 12 additions & 2 deletions src/atomics/Typography/TypographyText.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { forwardRef, useMemo } from 'react';
import { Skeleton } from '../../molecules';
import { TypographyTextStyles } from './styles';
import { RdTypographyTextProps } from './types';
import { Skeleton } from '../../molecules';
import { detectHeightBySize } from './TypographyText.helper';

export const TypographyText = forwardRef(
(props: RdTypographyTextProps, ref: RdTypographyTextProps['ref']) => {
Expand All @@ -14,7 +15,16 @@ export const TypographyText = forwardRef(
...antdProps
} = props;

if (loading) return <Skeleton.Input active />;
if (loading) {
return (
<Skeleton.Input
active
style={{
height: detectHeightBySize(size),
}}
/>
);
}

const editableCustom = useMemo(() => {
if (editable && typeof editable === 'object') {
Expand Down
59 changes: 59 additions & 0 deletions src/atomics/Typography/TypographyTitle.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { getAliasToken } from '../../utils';
import { RdTypographyTitleProps } from './types';

/**
* Calculates the visual height (in pixels) of a Typography Title component
* based on its `level` prop, using the corresponding `fontSize` and `lineHeight`
* token values from the theme (either component-specific or global).
*
* If an invalid level is provided (not from 1 to 5), it falls back to using
* the level 1 (`fontSizeHeading1` and `lineHeightHeading1`) as default.
*
* @param level - The `level` prop of a `Typography.Title` component (typically from 1 to 5).
* @returns The computed height in pixels (number), calculated as `fontSize * lineHeight`.
*
* @example
* ```ts
* const h1Height = detectHeightByLevel(1);
* console.log(h1Height); // Example: 42 (depending on token values)
*
* const invalidHeight = detectHeightByLevel();
* console.log(invalidHeight); // Fallbacks to heading1 height
* ```
*/
export const detectHeightByLevel = (level: RdTypographyTitleProps['level']) => {
// Detect fontSize and lineHeight based on `level` prop
let detectedFontSize: number | null = null;
let detectedLineHeight: number | null = null;

switch (level) {
case 1:
detectedFontSize = getAliasToken('Typography', 'fontSizeHeading1') as number;
detectedLineHeight = getAliasToken('Typography', 'lineHeightHeading1') as number;
break;
case 2:
detectedFontSize = getAliasToken('Typography', 'fontSizeHeading2') as number;
detectedLineHeight = getAliasToken('Typography', 'lineHeightHeading2') as number;
break;
case 3:
detectedFontSize = getAliasToken('Typography', 'fontSizeHeading3') as number;
detectedLineHeight = getAliasToken('Typography', 'lineHeightHeading3') as number;
break;
case 4:
detectedFontSize = getAliasToken('Typography', 'fontSizeHeading4') as number;
detectedLineHeight = getAliasToken('Typography', 'lineHeightHeading4') as number;
break;
case 5:
detectedFontSize = getAliasToken('Typography', 'fontSizeHeading5') as number;
detectedLineHeight = getAliasToken('Typography', 'lineHeightHeading5') as number;
break;
default:
// fallback to level 1 if the level is invalid
detectedFontSize = getAliasToken('Typography', 'fontSizeHeading1') as number;
detectedLineHeight = getAliasToken('Typography', 'lineHeightHeading1') as number;
}

const detectedHeight = detectedFontSize * detectedLineHeight;

return detectedHeight;
};
12 changes: 11 additions & 1 deletion src/atomics/Typography/TypographyTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ import { forwardRef } from 'react';
import { Skeleton } from '../../molecules';
import { TypographyTitleStyles } from './styles';
import { RdTypographyTitleProps } from './types';
import { detectHeightByLevel } from './TypographyTitle.helper';

export const TypographyTitle = forwardRef(
(props: RdTypographyTitleProps, ref: RdTypographyTitleProps['ref']) => {
const { disableMargin, loading, ...antdProps } = props;

if (loading) return <Skeleton.Input active />;
if (loading) {
return (
<Skeleton.Input
active
style={{
height: detectHeightByLevel(props.level),
}}
/>
);
}

return <TypographyTitleStyles disableMargin={disableMargin} ref={ref} {...antdProps} />;
}
Expand Down
12 changes: 6 additions & 6 deletions src/atomics/Typography/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { Typography } from 'antd';
import { getComponentOrGlobalToken } from '../../utils/token';
import { RdTypographyParagraphProps, RdTypographyTextProps, RdTypographyTitleProps } from './types';
import { css } from '@emotion/react';
import { getExcludeForwardProps } from '../../utils/styles';
import { RdTypographyParagraphProps, RdTypographyTextProps, RdTypographyTitleProps } from './types';
import { getAliasToken } from '../../utils';

export const TypographyLinkStyles = styled(Typography.Link)``;

Expand Down Expand Up @@ -35,7 +35,7 @@ export const TypographyTextStyles = styled(Typography.Text, {
switch (size) {
case 'small':
return `
font-size: ${getComponentOrGlobalToken('Typography', 'fontSizeSM')}px;
font-size: ${getAliasToken('Typography', 'fontSizeSM')}px;
`;
}
}}
Expand All @@ -61,8 +61,8 @@ export const TypographyParagraphStyles = styled(Typography.Paragraph, {
return (
minRows &&
css`
min-height: ${Number(getComponentOrGlobalToken('Typography', 'lineHeight')) *
Number(getComponentOrGlobalToken('Typography', 'fontSize')) *
min-height: ${Number(getAliasToken('Typography', 'lineHeight')) *
Number(getAliasToken('Typography', 'fontSize')) *
minRows}px;
`
);
Expand Down
1 change: 1 addition & 0 deletions src/atomics/Typography/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ export type RdTypographyTitleProps = TypographyTitleProps & TypographyTitleProps

export type RdTypographyComponentToken = TypographyComponentTokenAntd &
TypographyComponentTokenExtend;

//#endregion
20 changes: 20 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { theme } from 'antd';
import { RdThemeConfig } from './organisms';

export interface IConfig {
designToken: NonNullable<RdThemeConfig['token']>;
componentToken: RdThemeConfig['components'];
}

const defaultDesignToken = theme.getDesignToken(theme.defaultConfig);

export var config: IConfig = {
designToken: defaultDesignToken,
componentToken: {},
};

declare module 'antd' {
interface DefaultOptionType {
value?: string | number | boolean | null;
}
}
20 changes: 5 additions & 15 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { theme } from 'antd';
import { RdThemeConfig } from './organisms';
export * from '@ant-design/icons';

export interface IConfig {
designToken: NonNullable<RdThemeConfig['token']>;
componentToken: RdThemeConfig['components'];
}

export const config: IConfig = {
designToken: theme.getDesignToken(theme.defaultConfig),
componentToken: {},
};
export * from './config';
export * from './types';
export * from './utils';

export * from './atomics';
export * from './molecules';
export * from './organisms';
export * from './templates';
export * from './utils';

export * from './types'
export * from './templates';
3 changes: 2 additions & 1 deletion src/molecules/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./Button";
export * from "./types";
export * from "./types";
export * from './token'
4 changes: 2 additions & 2 deletions src/molecules/Button/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { Button } from 'antd';
import { getComponentOrGlobalToken, getExcludeForwardProps } from '../../utils';
import { getAliasToken, getExcludeForwardProps } from '../../utils';
import { RdButtonComponent, RdButtonGroupProps, RdButtonProps } from './types';

export const ButtonStyles = styled(Button as RdButtonComponent, {
Expand All @@ -20,7 +20,7 @@ export const ButtonStyles = styled(Button as RdButtonComponent, {
case 'success':
return css`
&.ant-btn {
color: ${getComponentOrGlobalToken('Button', 'colorSuccess')};
color: ${getAliasToken('Button', 'colorSuccess')};
}
`;
default:
Expand Down
Loading
Loading