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

Function prepareVariant

docs/src/utils/themes.tsx:172–208  ·  view source on GitHub ↗
({
  primary,
  secondary,
  tertiary,
  type,
  custom,
}: CustomTheme)

Source from the content-addressed store, hash-verified

170};
171
172export const prepareVariant = ({
173 primary,
174 secondary,
175 tertiary,
176 type,
177 custom,
178}: CustomTheme) => {
179 const baseTheme = argbThemeFromColor(primary, type);
180
181 if (secondary) {
182 const secondaryTheme = argbThemeFromColor(secondary, type);
183 baseTheme.secondary = secondaryTheme.primary;
184 baseTheme.onSecondary = secondaryTheme.onPrimary;
185 baseTheme.secondaryContainer = secondaryTheme.primaryContainer;
186 baseTheme.onSecondaryContainer = secondaryTheme.onPrimaryContainer;
187 }
188
189 if (tertiary) {
190 const tertiaryTheme = argbThemeFromColor(tertiary, type);
191 baseTheme.tertiary = tertiaryTheme.primary;
192 baseTheme.onTertiary = tertiaryTheme.onPrimary;
193 baseTheme.tertiaryContainer = tertiaryTheme.primaryContainer;
194 baseTheme.onTertiaryContainer = tertiaryTheme.onPrimaryContainer;
195 }
196
197 const theme = argbThemeToRgbTheme(baseTheme);
198 const elevation = prepareElevations(baseTheme);
199 const surfaceColors = prepareSurfaceColors(baseTheme);
200 const customColors = prepareCustomColors(type, custom);
201
202 return {
203 ...theme,
204 elevation,
205 ...surfaceColors,
206 ...customColors,
207 };
208};
209
210export const prepareThemes = (colors: RGBColorList) => {
211 const light = prepareVariant({

Callers 1

prepareThemesFunction · 0.85

Calls 5

argbThemeFromColorFunction · 0.85
argbThemeToRgbThemeFunction · 0.85
prepareElevationsFunction · 0.85
prepareSurfaceColorsFunction · 0.85
prepareCustomColorsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…