Skip to content

Commit

Permalink
feat: add isMobile property (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
korvin89 authored Nov 8, 2022
1 parent 9d0dd26 commit a2e87ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/ChartKit.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.chartkit {
height: 100%;
width: 100%;

&_mobile .chartkit-scrollable-node {
max-height: 3000px;
}
}
4 changes: 2 additions & 2 deletions src/components/ChartKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ChartKitComponentProps<T extends ChartkitType> = Omit<ChartKitProps<T>, 'on

const ChartKitComponent = <T extends ChartkitType>(props: ChartKitComponentProps<T>) => {
const widgetRef = React.useRef<ChartKitWidgetRef>();
const {instanceRef, id = getRandomCKId(), type, data, onLoad, ...restProps} = props;
const {instanceRef, id = getRandomCKId(), type, data, onLoad, isMobile, ...restProps} = props;
const lang = settings.get('lang');
const plugins = settings.get('plugins');
const plugin = plugins.find((iteratedPlugin) => iteratedPlugin.type === type);
Expand Down Expand Up @@ -46,7 +46,7 @@ const ChartKitComponent = <T extends ChartkitType>(props: ChartKitComponentProps

return (
<React.Suspense fallback={<Loader />}>
<div className={b()}>
<div className={b({mobile: isMobile})}>
<ChartComponent
ref={widgetRef}
id={id}
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type ChartKitProps<T extends ChartkitType> = {
type: T;
data: ChartkitWidget[T]['data'];
id?: string;
isMobile?: boolean;
onLoad?: (data?: ChartKitOnLoadData<T>) => void;
onError?: ChartKitOnError;
formatNumber?: ChartKitFormatNumber;
Expand Down

0 comments on commit a2e87ed

Please sign in to comment.