Skip to content

An open source alternative to Tableau. Embeddable visual analytic

chore:improve height style (#457)

islxyqwe88590a372fc4
diff --git a/packages/graphic-walker/index.html b/packages/graphic-walker/index.html
index f201fa10..1222607e 100644
--- a/packages/graphic-walker/index.html
+++ b/packages/graphic-walker/index.html
@@ -8,7 +8,7 @@
<meta name="description" content="An easy to use Exploratory Data Analysis tool">
</head>
<body>
- <div id="root"></div>
+ <div id="root" style="height: 100dvh; display: flex; flex-direction: column;"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
diff --git a/packages/graphic-walker/src/App.tsx b/packages/graphic-walker/src/App.tsx
index b614bf90..e4b9ac08 100644
--- a/packages/graphic-walker/src/App.tsx
+++ b/packages/graphic-walker/src/App.tsx
@@ -158,11 +158,11 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
vegaThemeContext={{ vizThemeConfig: currentTheme, setVizThemeConfig: setCurrentTheme }}
portalContainerContext={portal}
>
- <div className={classNames(`App font-sans bg-background text-foreground m-0 p-0`, darkMode === 'dark' ? 'dark' : '')}>
+ <div className={classNames(`App font-sans bg-background text-foreground m-0 p-0 w-full h-full`, darkMode === 'dark' ? 'dark' : '')}>
<FieldsContextWrapper>
- <div className="bg-background text-foreground">
+ <div className="bg-background text-foreground w-full h-full">
<Errorpanel />
- <Tabs value={segmentKey} onValueChange={(v) => vizStore.setSegmentKey(v as ISegmentKey)}>
+ <Tabs value={segmentKey} onValueChange={(v) => vizStore.setSegmentKey(v as ISegmentKey)} className='w-full h-full flex flex-col'>
<TabsList className="mx-4">
<TabsTrigger value={ISegmentKey.data}>
<CircleStackIcon className="w-4 mr-2" /> {t('App.segments.data')}
@@ -181,7 +181,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
<DatasetConfig />
</div>
</TabsContent>
- <TabsContent value={ISegmentKey.vis}>
+ <TabsContent value={ISegmentKey.vis} className='flex-1 min-h-0 flex flex-col'>
{!props.hideChartNav && (
<div className="px-2 mx-2 mt-2">
<VisNav />
@@ -190,7 +190,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
<div
style={{ marginTop: '0em' }}
className={cn(
- 'm-4 p-4 border border-border rounded-md rounded-tl-none',
+ 'm-4 p-4 border border-border rounded-md rounded-tl-none flex-1 min-h-0 flex flex-col',
props.hideChartNav ? 'border-t-0 rounded-t-none' : ''
)}
>
@@ -221,11 +221,11 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
<ComputedFieldDialog />
<Painter themeConfig={appliedThemeConfig} themeKey={appliedThemeKey} />
{vizStore.showGeoJSONConfigPanel && <GeoConfigPanel geoList={props.geoList} />}
- <div className="sm:flex">
+ <div className="sm:flex flex-1 min-h-0">
<SideResize
defaultWidth={240}
handleWidth={4}
- className="min-w-[100%] max-w-full sm:min-w-[96px] sm:max-w-[35%] flex-shrink-0"
+ className="min-w-[100%] max-w-full sm:min-w-[96px] sm:max-w-[35%] flex-shrink-0 sm:min-h-full flex flex-col"
handlerClassName="hidden sm:block"
>
<DatasetFields />
@@ -233,18 +233,18 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
<SideResize
defaultWidth={180}
handleWidth={4}
- className="min-w-[100%] max-w-full sm:min-w-[164px] sm:max-w-[314px] flex-shrink-0"
+ className="min-w-[100%] max-w-full sm:min-w-[164px] sm:max-w-[314px] flex-shrink-0 flex flex-col"
handlerClassName="hidden sm:block"
>
<FilterField />
<AestheticFields />
</SideResize>
- <div className="flex-1 min-w-[0px]">
+ <div className="flex-1 min-w-[0px] flex flex-col">
<div>
<PosFields />
</div>
<div
- className="my-0.5 sm:ml-0.5 p-1 border relative h-[600px]"
+ className="my-0.5 sm:ml-0.5 p-1 border relative flex-1 min-h-0"
onMouseLeave={() => {
vizEmbededMenu.show && vizStore.closeEmbededMenu();
}}
diff --git a/packages/graphic-walker/src/fields/aestheticFields.tsx b/packages/graphic-walker/src/fields/aestheticFields.tsx
index 58305ceb..3e9f6611 100644
--- a/packages/graphic-walker/src/fields/aestheticFields.tsx
+++ b/packages/graphic-walker/src/fields/aestheticFields.tsx
@@ -43,7 +43,7 @@ const AestheticFields: React.FC = (props) => {
}, [geoms[0]]);
return (
- <div>
+ <div className='min-h-0 overflow-y-auto'>
{channels.map((dkey, i, { length }) => {
if (GLOBAL_CONFIG.CHANNEL_LIMIT[dkey.id] === 1) {
return (
diff --git a/packages/graphic-walker/src/fields/datasetFields/index.tsx b/packages/graphic-walker/src/fields/datasetFields/index.tsx
index ff9ce03b..6645c97a 100644
--- a/packages/graphic-walker/src/fields/datasetFields/index.tsx
+++ b/packages/graphic-walker/src/fields/datasetFields/index.tsx
@@ -1,27 +1,20 @@
import React from 'react';
import { Droppable } from '@kanaries/react-beautiful-dnd';
import { useTranslation } from 'react-i18next';
-import styled from 'styled-components';
import DimFields from './dimFields';
import MeaFields from './meaFields';
import { refMapper } from '../fieldsContext';
-const DSContainer = styled.div`
- @media (min-width: 640px) {
- height: 680px;
- }
-`;
-
const DatasetFields: React.FC = (props) => {
const { t } = useTranslation('translation', { keyPrefix: 'main.tabpanel.DatasetFields' });
return (
- <DSContainer className="p-1 sm:mr-0.5 my-0.5 border flex sm:flex-col" style={{ paddingBlock: 0, paddingInline: '0.6em' }}>
+ <div className="p-1 sm:mr-0.5 my-0.5 border flex sm:flex-col sm:h-full" style={{ paddingBlock: 0, paddingInline: '0.6em' }}>
<h4 className="text-xs mb-2 flex-grow-0 cursor-default select-none mt-2">{t('field_list')}</h4>
<Droppable droppableId="dimensions" direction="vertical">
{(provided, snapshot) => (
- <div className="flex-shrink min-w-[0px] min-h-[100px] max-h-[380px]" {...provided.droppableProps} ref={refMapper(provided.innerRef)}>
- <div className="pd-1 overflow-y-auto h-full">
+ <div className="flex-shrink min-w-[0px] min-h-[100px] sm:max-h-[380px] sm:overflow-y-auto" {...provided.droppableProps} ref={refMapper(provided.innerRef)}>
+ <div className="pd-1">
<DimFields />
</div>
</div>
@@ -29,14 +22,14 @@ const DatasetFields: React.FC = (props) => {
</Droppable>
<Droppable droppableId="measures" direction="vertical">
{(provided, snapshot) => (
- <div className="flex-shrink flex-grow min-w-[0px] min-h-[200px]" {...provided.droppableProps} ref={refMapper(provided.innerRef)}>
+ <div className="flex-shrink flex-grow min-w-[0px] min-h-[200px] sm:overflow-y-auto flex-1" {...provided.droppableProps} ref={refMapper(provided.innerRef)}>
<div className="border-t flex-grow pd-1 overflow-y-auto h-full">
<MeaFields />
</div>
</div>
)}
</Droppable>
- </DSContainer>
+ </div>
);
};
diff --git a/packages/graphic-walker/src/fields/fieldsContext.tsx b/packages/graphic-walker/src/fields/fieldsContext.tsx
index df8618dd..783b19e2 100644
--- a/packages/graphic-walker/src/fields/fieldsContext.tsx
+++ b/packages/graphic-walker/src/fields/fieldsContext.tsx
@@ -102,7 +102,7 @@ export const FieldsContextWrapper: React.FC<{ children?: React.ReactNode | Itera
);
return (
<blockContext.Provider value={blockRef}>
- <div className="scale-100" ref={blockRef}>
+ <div className="scale-100 w-full h-full" ref={blockRef}>
<DragDropContext enableDefaultSensors={false} sensors={sensors} onDragEnd={onDragEnd} onDragStart={() => {}} onDragUpdate={() => {}}>
{props.children}
</DragDropContext>
diff --git a/packages/graphic-walker/src/main.tsx b/packages/graphic-walker/src/main.tsx
index 32cc3c19..d5b87a27 100644
--- a/packages/graphic-walker/src/main.tsx
+++ b/packages/graphic-walker/src/main.tsx
@@ -15,4 +15,8 @@ embedGraphicWalker(document.getElementById('root') as HTMLElement, {
url: 'https://raw.githubusercontent.com/drei01/geojson-world-cities/f2a988af4bc15463df55586afbbffbd3068b7218/cities.geojson',
},
],
+ style: {
+ flex: 1,
+ minHeight: 0
+ }
});
diff --git a/packages/graphic-walker/src/root.tsx b/packages/graphic-walker/src/root.tsx
index fb7a08df..7325831f 100644
--- a/packages/graphic-walker/src/root.tsx
+++ b/packages/graphic-walker/src/root.tsx
@@ -19,11 +19,28 @@ import './empty_sheet.css';
import { TableAppWithContext } from './Table';
import { RendererAppWithContext } from './Renderer';
-export type ILocalVizAppProps = IVizAppProps & ILocalComputationProps & React.RefAttributes<IGWHandler>;
-export type IRemoteVizAppProps = IVizAppProps & IRemoteComputationProps & React.RefAttributes<IGWHandler>;
+export type ILocalVizAppProps = IVizAppProps &
+ ILocalComputationProps &
+ React.RefAttributes<IGWHandler> & {
+ className?: string;
+ style?: React.CSSProperties;
+ };
+export type IRemoteVizAppProps = IVizAppProps &
+ IRemoteComputationProps &
+ React.RefAttributes<IGWHandler> & {
+ className?: string;
+ style?: React.CSSProperties;
+ };
export const GraphicWalker = observer(
- forwardRef<IGWHandler, IVizAppProps & (ILocalComputationProps | IRemoteComputationProps)>((props, ref) => {
+ forwardRef<
+ IGWHandler,
+ IVizAppProps &
+ (ILocalComputationProps | IRemoteComputationProps) & {
+ className?: string;
+ style?: React.CSSProperties;
+ }
+ >((props, ref) => {
const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);
const handleMount = (shadowRoot: ShadowRoot) => {
@@ -35,7 +52,13 @@ export const GraphicWalker = observer(
return (
<AppRoot ref={ref as ForwardedRef<IGWHandlerInsider>}>
- <ShadowDom onMount={handleMount} onUnmount={handleUnmount} uiTheme={props.uiTheme ?? props.colorConfig}>
+ <ShadowDom
+ className={props.className}
+ style={props.style}
+ onMount={handleMount}
+ onUnmount={handleUnmount}
+ uiTheme={props.uiTheme ?? props.colorConfig}
+ >
<DOMProvider value={{ head: shadowRoot ?? document.head, body: shadowRoot ?? document.body }}>
<VizAppWithContext {...props} />
</DOMProvider>
@@ -80,11 +103,28 @@ export const GraphicRenderer = observer(
(p: IRemoteVizAppProps & IRendererProps): JSX.Element;
};
-export type ILocalTableProps = ITableProps & ILocalComputationProps & React.RefAttributes<IGWHandler>;
-export type IRemoteTableProps = ITableProps & IRemoteComputationProps & React.RefAttributes<IGWHandler>;
+export type ILocalTableProps = ITableProps &
+ ILocalComputationProps &
+ React.RefAttributes<IGWHandler> & {
+ className?: string;
+ style?: React.CSSProperties;
+ };
+export type IRemoteTableProps = ITableProps &
+ IRemoteComputationProps &
+ React.RefAttributes<IGWHandler> & {
+ className?: string;
+ style?: React.CSSProperties;
+ };
export const TableWalker = observer(
- forwardRef<IGWHandler, ITableProps & IComputationProps>((props, ref) => {
+ forwardRef<
+ IGWHandler,
+ ITableProps &
+ IComputationProps & {
+ className?: string;
+ style?: React.CSSProperties;
+ }
+ >((props, ref) => {
const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);
const handleMount = (shadowRoot: ShadowRoot) => {
@@ -97,7 +137,13 @@ export const TableWalker = observer(
return (
<AppRoot ref={ref as ForwardedRef<IGWHandlerInsider>}>
<ShadowDom
- style={{ width: '100%', height: '100%' }}
+ style={
+ props.style ?? {
+ width: '100%',
+ height: '100%',
+ }
+ }
+ className={props.className}
onMount={handleMount}
onUnmount={handleUnmount}
uiTheme={props.uiTheme ?? props.colorConfig}
diff --git a/packages/playground/index.html b/packages/playground/index.html
index e164f1e5..2a5c0804 100644
--- a/packages/playground/index.html
+++ b/packages/playground/index.html
@@ -15,7 +15,7 @@
</script>
</head>
<body>
- <div id="root"></div>
+ <div id="root" style="height: 100dvh; display: flex; flex-direction: column;"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
diff --git a/packages/playground/src/main.tsx b/packages/playground/src/main.tsx
index bc0c0b86..171d8766 100644
--- a/packages/playground/src/main.tsx
+++ b/packages/playground/src/main.tsx
@@ -15,4 +15,8 @@ embedGraphicWalker(document.getElementById('root') as HTMLElement, {
url: 'https://raw.githubusercontent.com/drei01/geojson-world-cities/f2a988af4bc15463df55586afbbffbd3068b7218/cities.geojson',
},
],
+ style: {
+ flex: 1,
+ minHeight: 0
+ }
});