Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
skokenes committed Nov 11, 2024
1 parent f03417c commit 55b2568
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
40 changes: 22 additions & 18 deletions packages/malloy-render/src/component/chart/chart-dev-tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from 'solid-js';
import {Chart, ChartProps} from './chart';
import {View, parse} from 'vega';
import {createStore, unwrap} from 'solid-js/store';
import {createStore} from 'solid-js/store';
import {addSignalListenerIfExists} from '../vega/vega-utils';

type ChartDevToolProps = {
onClose: () => void;
} & ChartProps;

function stripMalloyRecord(record: Record<string, any>) {
function stripMalloyRecord(record: Record<string, unknown>) {
for (const [key, value] of Object.entries(record)) {
if (key === '__malloyDataRecord') {
delete record['__malloyDataRecord'];
Expand All @@ -25,7 +25,7 @@ function stripMalloyRecord(record: Record<string, any>) {
if (Array.isArray(value)) {
value.forEach(stripMalloyRecord);
} else {
stripMalloyRecord(value);
stripMalloyRecord(value as Record<string, unknown>);
}
}
}
Expand All @@ -43,8 +43,10 @@ export default function ChartDevTool(props: ChartDevToolProps) {

const [view, setView] = createSignal<View | undefined>();

const [vegaSignals, setVegaSignals] = createStore<Record<string, any>>({});
const [vegaData, setVegaData] = createStore<Record<string, any[]>>({});
const [vegaSignals, setVegaSignals] = createStore<Record<string, unknown>>(
{}
);
const [vegaData, setVegaData] = createStore<Record<string, unknown[]>>({});

createEffect(() => {
const _view = view();
Expand All @@ -66,11 +68,13 @@ export default function ChartDevTool(props: ChartDevToolProps) {
});
}

const runtimeData = (_view as any)._runtime.data ?? {};
const runtimeData =
(_view as unknown as {_runtime: {data: Record<string, unknown>}})
._runtime.data ?? {};

for (const [dataName, initValue] of Object.entries(runtimeData)) {
if (dataName === 'root') continue;
let dataValues: Record<string, any>[] = [];
let dataValues: Record<string, unknown>[] = [];
const valueEntry = initValue?.['values']?.['value'];
if (Array.isArray(valueEntry)) {
dataValues = valueEntry.map(entry => {
Expand Down Expand Up @@ -98,8 +102,8 @@ export default function ChartDevTool(props: ChartDevToolProps) {
const getDataRowValues = values => {
return Object.entries(values).map(([key, value]) => {
if (key === '__source') {
const entry: any = Object.assign({}, value);
delete entry.__malloyDataRecord;
const entry: Record<string, string> = Object.assign({}, value);
delete entry['__malloyDataRecord'];
return entry;
}
return value;
Expand All @@ -111,7 +115,7 @@ export default function ChartDevTool(props: ChartDevToolProps) {
return (
<div
style={{
'z-index': 1000,
['z-index']: 1000,
height: '100vh',
width: '100vw',
position: 'fixed',
Expand All @@ -124,14 +128,14 @@ export default function ChartDevTool(props: ChartDevToolProps) {
<div
style={{
display: 'grid',
'grid-template-columns': 'minmax(0, 640px) 1fr',
'height': '100%',
['grid-template-columns']: 'minmax(0, 640px) 1fr',
height: '100%',
}}
>
<div style="display: flex; flex-direction: column;">
<textarea
style={{
padding: '16px',
'padding': '16px',
'box-sizing': 'border-box',
'flex-grow': 1,
}}
Expand All @@ -152,13 +156,13 @@ export default function ChartDevTool(props: ChartDevToolProps) {
</div>
<div
style={{
padding: '16px',
background: '#eee',
height: '100%',
'padding': '16px',
'background': '#eee',
'height': '100%',
'box-sizing': 'border-box',
display: 'grid',
'display': 'grid',
'grid-template-rows': 'max-content 1fr',
overflow: 'hidden',
'overflow': 'hidden',
}}
>
<div style="background: white">
Expand Down
12 changes: 8 additions & 4 deletions packages/malloy-render/src/component/chart/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ const ChartDevTool = lazy(() => import('./chart-dev-tool'));

let IS_STORYBOOK = false;
try {
const storybookConfig = (process.env as any).IS_STORYBOOK;
const storybookConfig = (process.env as Record<string, string>)[
'IS_STORYBOOK'
];
if (typeof storybookConfig !== 'undefined')
IS_STORYBOOK = Boolean(storybookConfig);
} catch (e) {}
} catch (e) {
// Continue with storybook flag off
}

export type ChartProps = {
field: Explore | ExploreField;
Expand Down Expand Up @@ -200,10 +204,10 @@ export function Chart(props: ChartProps) {
explore={props.field}
runtime={runtime}
/>
<Tooltip show={!!tooltipData()}>
<Tooltip show={Boolean(tooltipData())}>
<DefaultChartTooltip data={tooltipData()!} />
</Tooltip>
<Show when={IS_STORYBOOK && !Boolean(props.devMode)}>
<Show when={IS_STORYBOOK && !props.devMode}>
<button class="malloy-chart_debug_menu" onClick={openDebug}>
<DebugIcon />
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {getChartLayoutSettings} from '../chart-layout-settings';
import {renderTimeString} from '../render-time';
import {createMeasureAxis} from '../vega/measure-axis';
import {
BaseMark,
Data,
GroupMark,
Item,
Expand Down
1 change: 1 addition & 0 deletions packages/malloy-render/src/component/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function MalloyRender(
function addCSSToShadowRoot(css: string) {
const root = element.renderRoot;
if (!(root instanceof ShadowRoot)) {
// eslint-disable-next-line no-console
console.warn(
"Couldn't add CSS to render element, it is not rendering in a ShadowRoot"
);
Expand Down

0 comments on commit 55b2568

Please sign in to comment.