Skip to content

Commit 1cfe813

Browse files
committed
feat(StructuredYson): add configurable collapse indicators
1 parent e66f983 commit 1cfe813

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/ReactUnipika/ReactUnipika.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const defaultUnipikaSettings = {
3030
escapeWhitespace: true,
3131
showDecoded: true,
3232
binaryAsHex: true,
33+
useIconsForCollapse: false,
3334
};
3435

3536
export function ReactUnipika({

src/StructuredYson/Cell.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export function Cell(props: CellProps) {
9090
collapsed={collapsed}
9191
path={path}
9292
onToggle={handleToggleCollapse}
93+
settings={settings}
9394
/>
9495
)}
9596
<Key
@@ -287,14 +288,21 @@ interface ToggleCollapseProps {
287288
collapsed?: boolean;
288289
path?: UnipikaFlattenTreeItem['path'];
289290
onToggle: () => void;
291+
settings?: UnipikaSettings;
290292
}
291293

292294
function ToggleCollapseButton(props: ToggleCollapseProps) {
293-
const {collapsed, onToggle, path} = props;
295+
const {collapsed, onToggle, path, settings = {}} = props;
296+
const useIcons = settings.useIconsForCollapse;
297+
294298
return (
295299
<span title={path} className={block('collapse')}>
296300
<Button onClick={onToggle} view="flat-secondary" size={'s'}>
297-
<Icon className={'unipika'} data={collapsed ? ChevronRight : ChevronUp} />
301+
{useIcons ? (
302+
<Icon className={'unipika'} data={collapsed ? ChevronRight : ChevronUp} />
303+
) : (
304+
<span className={'unipika'}>{collapsed ? '[+]' : '[-]'}</span>
305+
)}
298306
</Button>
299307
</span>
300308
);

src/StructuredYson/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type UnipikaSettings = {
1414
maxStringSize?: number;
1515
omitStructNull?: boolean;
1616
treatValAsData?: boolean;
17+
useIconsForCollapse?: boolean;
1718

1819
validateSrcUrl?: (taggedTypeUrl: string) => boolean;
1920
normalizeUrl?: (url?: string) => string;

0 commit comments

Comments
 (0)