Skip to content

Commit 4718fa1

Browse files
author
Kubit
committed
Improve stories for components
1 parent 2efc6cb commit 4718fa1

File tree

4 files changed

+11
-48
lines changed

4 files changed

+11
-48
lines changed

src/components/slider/utils/slider.utils.ts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { translateValue } from '@/utils';
2+
13
import { SliderOffsetBoundaries, SliderType } from '../types';
24

35
export const calculateChange = ({
@@ -239,46 +241,6 @@ export const getScale = ({
239241
return { showScale, scaleOffsets };
240242
};
241243

242-
/**
243-
* Translates a value from one range to another.
244-
*
245-
* @param inputMin - The minimum value of the input range.
246-
* @param inputMax - The maximum value of the input range.
247-
* @param outputMin - The minimum value of the output range.
248-
* @param outputMax - The maximum value of the output range.
249-
* @param value - The input value to be translated.
250-
*
251-
* @returns The translated value in the output range.
252-
*
253-
* @example
254-
* // Translates 50 from the range [0, 100] to the range [5, 10]
255-
* const output = translateValue({inputMin: 0, inputMax: 100, outputMin: 5, outputMax: 10, value: 50});
256-
* console.log(output); // 7.5
257-
*/
258-
const translateValue = ({
259-
inputMin,
260-
inputMax,
261-
outputMin,
262-
outputMax,
263-
value,
264-
}: {
265-
inputMin: number;
266-
inputMax: number;
267-
outputMin: number;
268-
outputMax: number;
269-
value: number;
270-
}): number => {
271-
const inputRange = inputMax - inputMin;
272-
const outputRange = outputMax - outputMin;
273-
274-
const scaledInputValue = (value - inputMin) / inputRange;
275-
276-
let outputValue = outputMin + scaledInputValue * outputRange;
277-
outputValue = Math.min(outputMax, Math.max(outputMin, outputValue));
278-
279-
return outputValue;
280-
};
281-
282244
export const getOffset = ({
283245
range,
284246
max,

src/components/storybook/replaceContent/replaceContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface IReplaceContent extends AriaType {
1313
id?: string;
1414
role?: ROLES;
1515
as?: React.ElementType;
16+
tabIndex?: number;
1617
}
1718

1819
export const ReplaceContent = React.forwardRef(

src/components/table/__tests__/table.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ const mockDivider = {
331331
dividerContent: {
332332
leftLabel: { content: '18 DIC Lorem ipsum' },
333333
icon: { icon: 'UNICORN', altText: 'Icon alt text' },
334-
tooltip: {
334+
iconTooltip: {
335335
title: { content: 'Tooltip title' },
336336
content: { content: 'Tooltip content' },
337337
},
@@ -352,7 +352,7 @@ const mockDividerFromHeader = {
352352
dividerContent: {
353353
leftLabel: { content: val.date },
354354
icon: { icon: 'UNICORN', altText: 'Icon alt text' },
355-
tooltip: {
355+
iconTooltip: {
356356
title: { content: 'Tooltip title' },
357357
content: { content: 'Tooltip content' },
358358
},

src/components/table/stories/mockDivider.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export const mockTableWithDivider = {
9494
transactionNumber: '0000',
9595
dividerContent: {
9696
leftLabel: { content: '18 DIC Lorem ipsum' },
97-
icon: { icon: 'UNICORN', altText: 'Icon alt text' },
98-
tooltip: {
97+
icon: { icon: ICONS.ICON_PLACEHOLDER, altText: 'Icon alt text' },
98+
iconTooltip: {
9999
title: { content: 'Tooltip title' },
100100
content: { content: 'Tooltip content' },
101101
},
@@ -110,8 +110,8 @@ export const mockTableWithDivider = {
110110
transactionNumber: '0000',
111111
dividerContent: {
112112
leftLabel: { content: '18 DIC Lorem ipsum' },
113-
icon: { icon: 'UNICORN', altText: 'Icon alt text' },
114-
tooltip: {
113+
icon: { icon: ICONS.ICON_PLACEHOLDER, altText: 'Icon alt text' },
114+
iconTooltip: {
115115
title: { content: 'Tooltip title' },
116116
content: { content: 'Tooltip content' },
117117
},
@@ -124,8 +124,8 @@ export const mockTableWithDivider = {
124124
accountNumber: '****333333',
125125
dividerContent: {
126126
leftLabel: { content: '19 DIC Lorem ipsum' },
127-
icon: { icon: 'UNICORN', altText: 'Icon alt text' },
128-
tooltip: {
127+
icon: { icon: ICONS.ICON_PLACEHOLDER, altText: 'Icon alt text' },
128+
iconTooltip: {
129129
title: { content: 'Tooltip title' },
130130
content: { content: 'Tooltip content' },
131131
},

0 commit comments

Comments
 (0)