@rango-dev/widget-embedded 0.23.1-next.16 → 0.23.1-next.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAmD5E,wBAAgB,eAAe,sBA8T9B"}
1
+ {"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAmD5E,wBAAgB,eAAe,sBA4T9B"}
@@ -159,8 +159,8 @@ export type Features = Partial<Record<'theme' | 'language' | 'connectWalletButto
159
159
  * that defines the various properties of the theme, such as colors, fonts, and others.
160
160
  * @property {boolean} externalWallets
161
161
  * If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
162
- * @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
163
- * set it to true, whenever a new liquidity source is added, it will be added to your list as well.
162
+ * @property {boolean} excludeLiquiditySources - The `excludeLiquiditySources` property is a boolean value that when you
163
+ * set it to true, the list of liquidity sources provided in `liquiditySources` will be excluded; otherwise, they will be included.
164
164
  * @property {Features} features - An optional object for configuring the visibility or enablement of various features.
165
165
  * Keys include:
166
166
  * - 'notification': Visibility state for the notification icon.
@@ -190,7 +190,7 @@ export type WidgetConfig = {
190
190
  language?: Language;
191
191
  theme?: WidgetTheme;
192
192
  externalWallets?: boolean;
193
- enableNewLiquiditySources?: boolean;
193
+ excludeLiquiditySources?: boolean;
194
194
  features?: Features;
195
195
  variant?: WidgetVariant;
196
196
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA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;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAChC,EAAE,CAAC,EAAE,wBAAwB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,iBAAiB,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import type { WidgetColors } from '../types';
2
- export declare const colorShade: (col: string, amt: number) => string;
3
- export declare const generateRangeColors: (name: string, color: string) => {
4
- [x: string]: string;
2
+ export declare function generateShades(baseColor: string, prefix: string, reverse?: boolean): {
3
+ [key: string]: string;
5
4
  };
5
+ export declare function generateShade(baseColor: string, decrementAmount: number): string;
6
+ export declare function convertToRGB(baseColor: string): number[];
7
+ export declare function isBright(baseColor: string): boolean;
6
8
  export declare const generateColors: (mainColors: {
7
9
  [x: string]: string;
8
10
  }, reverseNeutralRange: boolean, colors?: WidgetColors) => {
@@ -1 +1 @@
1
- {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,UAAU,CAAC;AAE/D,eAAO,MAAM,UAAU,QAAS,MAAM,OAAO,MAAM,WAyBlD,CAAC;AAEF,eAAO,MAAM,mBAAmB,SAAU,MAAM,SAAS,MAAM;;CAmC9D,CAAC;AACF,eAAO,MAAM,cAAc;;wBAEJ,OAAO,WACnB,YAAY;;CAyCtB,CAAC"}
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,UAAU,CAAC;AAE/D,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,GAChB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAyC3B;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,MAAM,CAKR;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBxD;AAcD,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,WAezC;AAED,eAAO,MAAM,cAAc;;wBAEJ,OAAO,WACnB,YAAY;;CA2BtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.23.1-next.16",
3
+ "version": "0.23.1-next.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  "@rango-dev/queue-manager-core": "^0.26.0",
26
26
  "@rango-dev/queue-manager-rango-preset": "^0.28.1-next.3",
27
27
  "@rango-dev/queue-manager-react": "^0.26.0",
28
- "@rango-dev/ui": "^0.29.1-next.11",
28
+ "@rango-dev/ui": "^0.29.1-next.13",
29
29
  "@rango-dev/wallets-react": "^0.14.1-next.1",
30
30
  "@rango-dev/wallets-shared": "^0.28.1-next.1",
31
31
  "bignumber.js": "^9.1.1",
@@ -48,4 +48,4 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  }
51
- }
51
+ }
@@ -55,19 +55,6 @@ export const QuoteContainer = styled(Collapsible.Root, {
55
55
  backgroundColor: '$$color',
56
56
  },
57
57
  },
58
- {
59
- listItem: true,
60
- selected: false,
61
- css: {
62
- cursor: 'pointer',
63
- '&:hover': {
64
- backgroundColor: '$neutral300',
65
- [`.${darkTheme} &`]: {
66
- backgroundColor: '$neutral400',
67
- },
68
- },
69
- },
70
- },
71
58
  ],
72
59
  });
73
60
 
@@ -107,6 +94,18 @@ export const SummaryContainer = styled('div', {
107
94
  },
108
95
  backgroundColor: '$$color',
109
96
  '&:hover': {
97
+ '& .quote_container': {
98
+ '& button': {
99
+ backgroundColor: '$neutral500',
100
+ [`.${darkTheme} &`]: {
101
+ backgroundColor: '$neutral200',
102
+ },
103
+ },
104
+ backgroundColor: '$neutral500',
105
+ [`.${darkTheme} &`]: {
106
+ backgroundColor: '$neutral200',
107
+ },
108
+ },
110
109
  backgroundColor: '$neutral300',
111
110
  [`.${darkTheme} &`]: {
112
111
  backgroundColor: '$neutral400',
@@ -376,6 +375,6 @@ export const Line = styled('div', {
376
375
  borderTopColor: '$neutral',
377
376
  margin: '$5 0',
378
377
  [`.${darkTheme} &`]: {
379
- borderTopColor: '$neutral400',
378
+ borderTopColor: '$neutral800',
380
379
  },
381
380
  });
@@ -438,6 +438,7 @@ export function Quote(props: QuoteProps) {
438
438
  selected={selected}
439
439
  listItem={type === 'list-item'}
440
440
  open={expanded}
441
+ className="quote_container"
441
442
  onOpenChange={setExpanded}>
442
443
  <QuoteTrigger
443
444
  type={type}
@@ -27,7 +27,7 @@ export const Steps = styled('div', {
27
27
  });
28
28
 
29
29
  export const StepSeparator = styled('div', {
30
- borderLeft: '1px dashed black',
30
+ borderLeft: '1px dashed $foreground',
31
31
  minHeight: ' 0',
32
32
  margin: '0px 11.5px',
33
33
  alignSelf: 'stretch',
@@ -1,5 +1,3 @@
1
- import type { PreferenceType } from 'rango-sdk';
2
-
3
1
  import { Select } from '@rango-dev/ui';
4
2
  import React from 'react';
5
3
 
@@ -16,17 +14,11 @@ export function SelectStrategy(props: { container: HTMLElement }) {
16
14
  <Select
17
15
  container={props.container}
18
16
  options={ROUTE_STRATEGY}
19
- value={
20
- ROUTE_STRATEGY.find(
21
- (strategy) => strategy.value === sortStrategy
22
- ) as {
23
- value: PreferenceType;
24
- label: string;
25
- }
26
- }
17
+ value={sortStrategy}
27
18
  handleItemClick={(item) => {
28
- updateQuotePartialState('sortStrategy', item.value as PreferenceType);
19
+ updateQuotePartialState('sortStrategy', item.value);
29
20
  }}
21
+ variant="filled"
30
22
  />
31
23
  </SelectContainer>
32
24
  );
@@ -19,7 +19,7 @@ import React, { useEffect, useState } from 'react';
19
19
 
20
20
  import { useAppStore } from '../../store/AppStore';
21
21
  import { useWalletsStore } from '../../store/wallets';
22
- import { generateRangeColors } from '../../utils/colors';
22
+ import { generateShade, isBright } from '../../utils/colors';
23
23
  import { formatBalance } from '../../utils/wallets';
24
24
 
25
25
  import { LoadingTokenList } from './LoadingTokenList';
@@ -133,23 +133,24 @@ export function TokenList(props: PropTypes) {
133
133
  const blockchain = blockchains.find(
134
134
  (blockchain) => blockchain.name === token.blockchain
135
135
  );
136
- const color = generateRangeColors(
137
- token.symbol,
138
- blockchain?.color || ''
136
+ const lightShade = generateShade(
137
+ blockchain?.color || '',
138
+ isBright(blockchain?.color || '') ? 5 : 125
139
139
  );
140
+ const darkShade = generateShade(blockchain?.color || '', -100);
140
141
 
141
142
  const customCssForTag = {
142
- $$color: color[`${token.symbol}100`],
143
+ $$color: lightShade,
143
144
  [`.${darkTheme} &`]: {
144
- $$color: color[`${token.symbol}900`],
145
+ $$color: darkShade,
145
146
  },
146
147
  backgroundColor: '$$color',
147
148
  };
148
149
 
149
150
  const customCssForTagTitle = {
150
- $$color: color[`${token.symbol}700`],
151
+ $$color: darkShade,
151
152
  [`.${darkTheme} &`]: {
152
- $$color: color[`${token.symbol}100`],
153
+ $$color: lightShade,
153
154
  },
154
155
  color: '$$color',
155
156
  };
@@ -46,7 +46,8 @@ export function useSwapInput({
46
46
  refetchQuote,
47
47
  }: UseSwapInputProps): UseSwapInput {
48
48
  const { fetch: fetchQuote, cancelFetch } = useFetchAllQuotes();
49
- const { enableNewLiquiditySources, features } = useAppStore().config;
49
+ const { excludeLiquiditySources: configExcludeLiquiditySources, features } =
50
+ useAppStore().config;
50
51
  const connectedWallets = useWalletsStore.use.connectedWallets();
51
52
 
52
53
  const tokens = useAppStore().tokens();
@@ -223,7 +224,7 @@ export function useSwapInput({
223
224
  toToken?.blockchain,
224
225
  shouldSkipRequest,
225
226
  liquiditySources?.length,
226
- enableNewLiquiditySources,
227
+ configExcludeLiquiditySources,
227
228
  disabledLiquiditySources.length,
228
229
  userSlippage,
229
230
  affiliateRef,
@@ -378,8 +378,6 @@ export function ConfirmSwapPage() {
378
378
  quote={selectedQuote}
379
379
  type="swap-preview"
380
380
  expanded={true}
381
- selected
382
- tagHidden
383
381
  error={confirmSwapResult.error}
384
382
  loading={fetchingConfirmationQuote}
385
383
  warning={confirmSwapResult.warnings?.quote ?? null}
@@ -6,7 +6,7 @@ export const DEFAULT_CONFIG: WidgetConfig = {
6
6
  apiKey: '',
7
7
  title: undefined,
8
8
  multiWallets: true,
9
- enableNewLiquiditySources: true,
9
+ excludeLiquiditySources: true,
10
10
  customDestination: true,
11
11
  };
12
12
 
@@ -72,7 +72,7 @@ export const createConfigSlice: StateCreatorWithInitialData<
72
72
  const { config, campaignMode } = get();
73
73
  return campaignMode.liquiditySources?.length
74
74
  ? false
75
- : !!config.enableNewLiquiditySources;
75
+ : !!config.excludeLiquiditySources;
76
76
  },
77
77
  isInCampaignMode: () => {
78
78
  const { campaignMode } = get();
@@ -177,12 +177,12 @@ export const createDataSlice: StateCreator<
177
177
  const liquiditySources =
178
178
  campaignModeLiquiditySource ?? config.liquiditySources;
179
179
 
180
- const enableNewLiquiditySources = campaignModeLiquiditySource
180
+ const excludeLiquiditySources = campaignModeLiquiditySource
181
181
  ? false
182
- : config.enableNewLiquiditySources;
182
+ : config.excludeLiquiditySources;
183
183
 
184
184
  /*
185
- * If the enableNewLiquiditySources flag is set to true, we return all swappers that are not included in the config.
185
+ * If the excludeLiquiditySources flag is set to true, we return all swappers that are not included in the config.
186
186
  * Otherwise, we return all swappers that are included in the config.
187
187
  */
188
188
  const swappers = get()._swappers.filter((swapper) => {
@@ -191,7 +191,7 @@ export const createDataSlice: StateCreator<
191
191
  );
192
192
 
193
193
  const shouldExcludeLiquiditySources =
194
- enableNewLiquiditySources ||
194
+ excludeLiquiditySources ||
195
195
  !liquiditySources ||
196
196
  liquiditySources.length === 0;
197
197
 
@@ -171,8 +171,8 @@ export type Features = Partial<
171
171
  * that defines the various properties of the theme, such as colors, fonts, and others.
172
172
  * @property {boolean} externalWallets
173
173
  * If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
174
- * @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
175
- * set it to true, whenever a new liquidity source is added, it will be added to your list as well.
174
+ * @property {boolean} excludeLiquiditySources - The `excludeLiquiditySources` property is a boolean value that when you
175
+ * set it to true, the list of liquidity sources provided in `liquiditySources` will be excluded; otherwise, they will be included.
176
176
  * @property {Features} features - An optional object for configuring the visibility or enablement of various features.
177
177
  * Keys include:
178
178
  * - 'notification': Visibility state for the notification icon.
@@ -203,7 +203,7 @@ export type WidgetConfig = {
203
203
  language?: Language;
204
204
  theme?: WidgetTheme;
205
205
  externalWallets?: boolean;
206
- enableNewLiquiditySources?: boolean;
206
+ excludeLiquiditySources?: boolean;
207
207
  features?: Features;
208
208
  variant?: WidgetVariant;
209
209
  };
@@ -1,68 +1,113 @@
1
1
  import type { WidgetColors, WidgetColorsKeys } from '../types';
2
2
 
3
- export const colorShade = (col: string, amt: number) => {
4
- const RANGE = 255;
5
- const COL = 3;
6
- const RADIX = 16;
7
-
8
- col = col.replace(/^#/, '');
9
- if (col.length === COL) {
10
- col = col[0] + col[0] + col[1] + col[1] + col[2] + col[2];
11
- }
12
- let [r, g, b]: any = col.match(/.{2}/g);
13
- [r, g, b] = [
14
- parseInt(r, RADIX) + amt,
15
- parseInt(g, RADIX) + amt,
16
- parseInt(b, RADIX) + amt,
17
- ];
18
-
19
- r = Math.max(Math.min(RANGE, r), 0).toString(RADIX);
20
- g = Math.max(Math.min(RANGE, g), 0).toString(RADIX);
21
- b = Math.max(Math.min(RANGE, b), 0).toString(RADIX);
22
-
23
- const rr = (r.length < 2 ? '0' : '') + r;
24
- const gg = (g.length < 2 ? '0' : '') + g;
25
- const bb = (b.length < 2 ? '0' : '') + b;
26
-
27
- return `#${rr}${gg}${bb}`;
28
- };
3
+ export function generateShades(
4
+ baseColor: string,
5
+ prefix: string,
6
+ reverse?: boolean
7
+ ): { [key: string]: string } {
8
+ const BASE_SHADE_INDEX = 100;
9
+ const NUMBER_OF_COLORS = 9;
10
+ const SHADING_INCREMENT_MAX = 10; // For bright colors
11
+ const SHADING_INCREMENT_MIN = 6; // For dark colors
29
12
 
30
- export const generateRangeColors = (name: string, color: string) => {
31
- const NUMBER_OF_COLORS = 10;
32
- const HALF_NUMBER_OF_COLORS = 5;
33
- const COLOR_SUFFIX = 100;
34
- const AMT = 25;
35
-
36
- let colors = { [name]: color };
37
- for (let i = 1; i < NUMBER_OF_COLORS; i++) {
38
- if (i < HALF_NUMBER_OF_COLORS) {
39
- colors = {
40
- ...colors,
41
- [name + i * COLOR_SUFFIX]: colorShade(
42
- color,
43
- (HALF_NUMBER_OF_COLORS - i) * AMT
44
- ),
45
- };
46
- }
47
- if (i === HALF_NUMBER_OF_COLORS) {
48
- colors = {
49
- ...colors,
50
- [name + i * COLOR_SUFFIX]: color,
51
- };
52
- }
53
- if (i > HALF_NUMBER_OF_COLORS) {
54
- colors = {
55
- ...colors,
56
- [name + i * COLOR_SUFFIX]: colorShade(
57
- color,
58
- -((i - HALF_NUMBER_OF_COLORS) * AMT)
59
- ),
60
- };
13
+ const HALF_NUMBER_OF_COLORS = 4;
14
+
15
+ const shadeIncrements: number[] = [];
16
+ let increment = 90;
17
+ for (let i = 0; i < NUMBER_OF_COLORS; i++) {
18
+ shadeIncrements.push(increment);
19
+ if (i + 1 === HALF_NUMBER_OF_COLORS) {
20
+ increment = 0;
21
+ } else {
22
+ increment -=
23
+ i >= HALF_NUMBER_OF_COLORS
24
+ ? SHADING_INCREMENT_MIN
25
+ : SHADING_INCREMENT_MAX;
61
26
  }
62
27
  }
63
28
 
64
- return colors;
65
- };
29
+ // If 'reverse' is true, that means the color should be from dark to light
30
+ const decrementAmounts = reverse
31
+ ? shadeIncrements.slice().reverse()
32
+ : shadeIncrements;
33
+
34
+ const shades: { [key: string]: string } = {};
35
+
36
+ // Generate shades
37
+ for (let i = 0; i < NUMBER_OF_COLORS; i++) {
38
+ const shadeIndex = BASE_SHADE_INDEX + i * BASE_SHADE_INDEX;
39
+ const decrementAmount = decrementAmounts[i];
40
+
41
+ const shade: { [key: string]: string } = {
42
+ [`${prefix}${shadeIndex}`]: generateShade(baseColor, decrementAmount),
43
+ };
44
+ Object.assign(shades, shade);
45
+ }
46
+
47
+ return { ...shades, [prefix]: baseColor };
48
+ }
49
+
50
+ export function generateShade(
51
+ baseColor: string,
52
+ decrementAmount: number
53
+ ): string {
54
+ const [r, g, b] = convertToRGB(baseColor);
55
+ return `#${clamp(r + decrementAmount)}${clamp(g + decrementAmount)}${clamp(
56
+ b + decrementAmount
57
+ )}`;
58
+ }
59
+
60
+ export function convertToRGB(baseColor: string): number[] {
61
+ const COLOR_SLICE_START = 1;
62
+ const COLOR_SLICE_END = 3;
63
+ const BASE_COLOR_LENGTH = 7;
64
+
65
+ // Convert the base color to RGB components
66
+ const r: number = parseInt(
67
+ baseColor.slice(COLOR_SLICE_START, COLOR_SLICE_END),
68
+ 16
69
+ );
70
+ const g: number = parseInt(
71
+ baseColor.slice(COLOR_SLICE_END, COLOR_SLICE_END + 2),
72
+ 16
73
+ );
74
+ const b: number = parseInt(
75
+ baseColor.slice(COLOR_SLICE_END + 2, BASE_COLOR_LENGTH),
76
+ 16
77
+ );
78
+
79
+ return [r, g, b];
80
+ }
81
+
82
+ // Function to clamp color component to valid range [0, 255] and convert to hex
83
+ function clamp(color: number): string {
84
+ const MAX_COLOR_VALUE = 255;
85
+ const HEX_BASE = 16;
86
+ const HEX_LENGTH = -2;
87
+ return (
88
+ '0' + Math.max(0, Math.min(MAX_COLOR_VALUE, color)).toString(HEX_BASE)
89
+ )
90
+ .slice(HEX_LENGTH)
91
+ .toUpperCase();
92
+ }
93
+
94
+ export function isBright(baseColor: string) {
95
+ const BRIGHTNESS_THRESHOLD = 188;
96
+ const RED_COEFFICIENT = 299;
97
+ const GREEN_COEFFICIENT = 587;
98
+ const BLUE_COEFFICIENT = 114;
99
+ const BRIGHTNESS_DIVISOR = 1000;
100
+
101
+ const [r, g, b] = convertToRGB(baseColor);
102
+ const brightness =
103
+ (r * RED_COEFFICIENT + g * GREEN_COEFFICIENT + b * BLUE_COEFFICIENT) /
104
+ BRIGHTNESS_DIVISOR;
105
+ if (brightness > BRIGHTNESS_THRESHOLD) {
106
+ return true;
107
+ }
108
+ return false;
109
+ }
110
+
66
111
  export const generateColors = (
67
112
  mainColors: { [x: string]: string },
68
113
  reverseNeutralRange: boolean,
@@ -83,25 +128,11 @@ export const generateColors = (
83
128
  ...listOfColors,
84
129
  [colorKey]: color,
85
130
  };
86
- } else if (colorKey === 'neutral' && reverseNeutralRange) {
87
- const range = generateRangeColors(colorKey, color);
88
- listOfColors = {
89
- ...listOfColors,
90
- // Reverse the neutral shade
91
- [`${colorKey}100`]: range[`${colorKey}900`],
92
- [`${colorKey}200`]: range[`${colorKey}800`],
93
- [`${colorKey}300`]: range[`${colorKey}700`],
94
- [`${colorKey}400`]: range[`${colorKey}600`],
95
- [`${colorKey}500`]: range[`${colorKey}500`],
96
- [`${colorKey}600`]: range[`${colorKey}400`],
97
- [`${colorKey}700`]: range[`${colorKey}300`],
98
- [`${colorKey}800`]: range[`${colorKey}200`],
99
- [`${colorKey}900`]: range[`${colorKey}100`],
100
- };
101
131
  } else {
132
+ const reverse = colorKey === 'neutral' && reverseNeutralRange;
102
133
  listOfColors = {
103
134
  ...listOfColors,
104
- ...generateRangeColors(colorKey, color),
135
+ ...generateShades(color, colorKey, reverse),
105
136
  };
106
137
  }
107
138
  }