Skip to content

Commit

Permalink
Merge pull request #37 from imagine10255/36-support-height-can-use-nu…
Browse files Browse the repository at this point in the history
…mber-auto-convert-to-px

support height can use number (auto convert to px) #36
  • Loading branch information
imagine10255 authored Oct 31, 2024
2 parents f412a78 + 4de8a73 commit 7c2adbc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export const WithStaticHeight: Story = {
height: '240px',
}
};
export const WithStaticHeightByNumber: Story = {
args: {
slidesPerView: 1,
height: 240,
}
};
export const WithAspectRatio: Story = {
args: {
slidesPerView: 1,
Expand Down
12 changes: 10 additions & 2 deletions src/manager/Configurator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ export function getMediaSetting(options?: {
};
}


/**
* 取得高度設定
* @param height
*/
export function getHeight(height: IBreakpointSetting['height']) {
if(typeof height === 'string'){
if(typeof height === 'number'){
return {
height: `${height}px`,
};

}else if(typeof height === 'string'){
if(height === 'auto'){
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface IBearSlideItemData {
export type TBearSlideItemDataList = ReactNode[];

export type heightUnit = 'px' | '%' | 'em' | 'rem' | 'vh';
export type THeightUnitSize = 'auto'|`${number}${heightUnit}`;
export type THeightUnitSize = 'auto'|number|`${number}${heightUnit}`;

export interface IAspectRatio {
widthRatio: number
Expand Down

0 comments on commit 7c2adbc

Please sign in to comment.