MCPcopy Create free account
hub / github.com/callstack/react-native-paper / prepareCustomColors

Function prepareCustomColors

docs/src/utils/themes.tsx:146–170  ·  view source on GitHub ↗
(
  type: 'light' | 'dark',
  custom?: [string, string][]
)

Source from the content-addressed store, hash-verified

144};
145
146const prepareCustomColors = (
147 type: 'light' | 'dark',
148 custom?: [string, string][]
149) => {
150 if (!custom?.length) {
151 return {};
152 }
153
154 let customColors: Record<string, string> = {};
155
156 for (let [name, value] of custom) {
157 if (name) {
158 const customColor = argbThemeToRgbTheme(argbThemeFromColor(value, type));
159 const camelName = camelCase(name);
160 const PascalName = camelCase(name, { pascalCase: true });
161
162 customColors[camelName] = customColor.primary;
163 customColors[`on${PascalName}`] = customColor.onPrimary;
164 customColors[`${camelName}Container`] = customColor.primaryContainer;
165 customColors[`on${PascalName}Container`] = customColor.onPrimaryContainer;
166 }
167 }
168
169 return customColors;
170};
171
172export const prepareVariant = ({
173 primary,

Callers 1

prepareVariantFunction · 0.85

Calls 2

argbThemeToRgbThemeFunction · 0.85
argbThemeFromColorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…