Skip to content

Commit

Permalink
Improve styilign
Browse files Browse the repository at this point in the history
  • Loading branch information
academo committed Mar 19, 2024
1 parent 9c13880 commit 827c6c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/components/options/ColumnSortingEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SelectableValue, StandardEditorProps } from '@grafana/data';
import { Box, Button, IconButton, InlineField, Select, Stack, Text } from '@grafana/ui';
import React from 'react';
import { Box, Button, IconButton, InlineField, Input, Select, Stack } from '@grafana/ui';
import React, { FormEvent } from 'react';
import { ColumnSorting, ColumnSortingOptions } from 'types';

function getSortingValue(item: string): ColumnSortingOptions {
Expand All @@ -19,10 +19,11 @@ export function ColumnSortingEditor(props: StandardEditorProps<ColumnSorting[]>)
onChange([...value.slice(0, index), ...value.slice(index + 1)]);
}

function handleIndexChange(event: React.ChangeEvent<HTMLInputElement>, selectIndex: number) {
function handleIndexChange(event: FormEvent<HTMLInputElement>, selectIndex: number) {
const target = event.target as HTMLInputElement;
const newSorting = value.map((item: ColumnSorting, itemIndex: number) => {
if (itemIndex === selectIndex) {
return { index: parseInt(event.target.value, 10), order: item.order };
return { index: parseInt(target.value, 10), order: item.order };
}
return item;
});
Expand All @@ -45,7 +46,7 @@ export function ColumnSortingEditor(props: StandardEditorProps<ColumnSorting[]>)
<div key={index} style={{ width: '100%' }}>
<Stack justifyContent="start" direction="row" alignItems="start">
<InlineField label="Column" tooltip="Name of the column to sort">
<input
<Input
type="number"
value={items.index}
onChange={(event) => {
Expand Down
11 changes: 6 additions & 5 deletions src/components/options/ColumnWidthHintsEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SelectableValue, StandardEditorProps } from '@grafana/data';
import { Box, Button, IconButton, InlineField, Select, Stack, Text } from '@grafana/ui';
import React from 'react';
import { Box, Button, IconButton, InlineField, Input, Select, Stack } from '@grafana/ui';
import React, { FormEvent } from 'react';
import { getDataFramesFields } from 'transformations';
import { ColumnWidthHint } from 'types';

Expand Down Expand Up @@ -34,10 +34,11 @@ export function ColumnWidthHints(props: StandardEditorProps<ColumnWidthHint[]>)
onChange(newWidths);
}

function handleWidthChange(event: React.ChangeEvent<HTMLInputElement>, selectIndex: number) {
function handleWidthChange(event: FormEvent<HTMLInputElement>, selectIndex: number) {
const target = event.target as HTMLInputElement;
const newWidths = value.map((item: ColumnWidthHint, index: number) => {
if (index === selectIndex) {
return { name: item.name, width: event.target.value };
return { name: item.name, width: target.value };
}
return item;
});
Expand All @@ -61,7 +62,7 @@ export function ColumnWidthHints(props: StandardEditorProps<ColumnWidthHint[]>)
/>
</InlineField>
<InlineField label="Width" tooltip="The width hint to apply. (add % or px)">
<input
<Input
value={item.width || ''}
onChange={(event) => {
handleWidthChange(event, index);
Expand Down

0 comments on commit 827c6c0

Please sign in to comment.