@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.
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quotes/SelectStrategy.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/colors.d.ts +5 -3
- package/dist/utils/colors.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Quote/Quote.styles.ts +13 -14
- package/src/components/Quote/Quote.tsx +1 -0
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +1 -1
- package/src/components/Quotes/SelectStrategy.tsx +3 -11
- package/src/components/TokenList/TokenList.tsx +9 -8
- package/src/hooks/useSwapInput.ts +3 -2
- package/src/pages/ConfirmSwapPage.tsx +0 -2
- package/src/store/slices/config.ts +2 -2
- package/src/store/slices/data.ts +4 -4
- package/src/types/config.ts +3 -3
- package/src/utils/colors.ts +106 -75
|
@@ -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,
|
|
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"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -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}
|
|
163
|
-
* set it to true,
|
|
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
|
-
|
|
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,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,eAAe,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,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AAQ,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"}
|
package/dist/utils/colors.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { WidgetColors } from '../types';
|
|
2
|
-
export declare
|
|
3
|
-
|
|
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,
|
|
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.
|
|
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.
|
|
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: '$
|
|
378
|
+
borderTopColor: '$neutral800',
|
|
380
379
|
},
|
|
381
380
|
});
|
|
@@ -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
|
|
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 {
|
|
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
|
|
137
|
-
|
|
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:
|
|
143
|
+
$$color: lightShade,
|
|
143
144
|
[`.${darkTheme} &`]: {
|
|
144
|
-
$$color:
|
|
145
|
+
$$color: darkShade,
|
|
145
146
|
},
|
|
146
147
|
backgroundColor: '$$color',
|
|
147
148
|
};
|
|
148
149
|
|
|
149
150
|
const customCssForTagTitle = {
|
|
150
|
-
$$color:
|
|
151
|
+
$$color: darkShade,
|
|
151
152
|
[`.${darkTheme} &`]: {
|
|
152
|
-
$$color:
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
75
|
+
: !!config.excludeLiquiditySources;
|
|
76
76
|
},
|
|
77
77
|
isInCampaignMode: () => {
|
|
78
78
|
const { campaignMode } = get();
|
package/src/store/slices/data.ts
CHANGED
|
@@ -177,12 +177,12 @@ export const createDataSlice: StateCreator<
|
|
|
177
177
|
const liquiditySources =
|
|
178
178
|
campaignModeLiquiditySource ?? config.liquiditySources;
|
|
179
179
|
|
|
180
|
-
const
|
|
180
|
+
const excludeLiquiditySources = campaignModeLiquiditySource
|
|
181
181
|
? false
|
|
182
|
-
: config.
|
|
182
|
+
: config.excludeLiquiditySources;
|
|
183
183
|
|
|
184
184
|
/*
|
|
185
|
-
* If the
|
|
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
|
-
|
|
194
|
+
excludeLiquiditySources ||
|
|
195
195
|
!liquiditySources ||
|
|
196
196
|
liquiditySources.length === 0;
|
|
197
197
|
|
package/src/types/config.ts
CHANGED
|
@@ -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}
|
|
175
|
-
* set it to true,
|
|
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
|
-
|
|
206
|
+
excludeLiquiditySources?: boolean;
|
|
207
207
|
features?: Features;
|
|
208
208
|
variant?: WidgetVariant;
|
|
209
209
|
};
|
package/src/utils/colors.ts
CHANGED
|
@@ -1,68 +1,113 @@
|
|
|
1
1
|
import type { WidgetColors, WidgetColorsKeys } from '../types';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
135
|
+
...generateShades(color, colorKey, reverse),
|
|
105
136
|
};
|
|
106
137
|
}
|
|
107
138
|
}
|