MCPcopy
hub / github.com/callstack/react-native-paper / getSelectedBackgroundColor

Function getSelectedBackgroundColor

src/components/Chip/helpers.tsx:142–198  ·  view source on GitHub ↗
({
  theme,
  isOutlined,
  disabled,
  customBackgroundColor,
  showSelectedOverlay,
}: BaseProps & {
  customBackgroundColor?: ColorValue;
  showSelectedOverlay?: boolean;
})

Source from the content-addressed store, hash-verified

140};
141
142const getSelectedBackgroundColor = ({
143 theme,
144 isOutlined,
145 disabled,
146 customBackgroundColor,
147 showSelectedOverlay,
148}: BaseProps & {
149 customBackgroundColor?: ColorValue;
150 showSelectedOverlay?: boolean;
151}) => {
152 const backgroundColor = getBackgroundColor({
153 theme,
154 disabled,
155 isOutlined,
156 customBackgroundColor,
157 });
158
159 if (theme.isV3) {
160 if (isOutlined) {
161 if (showSelectedOverlay) {
162 return color(backgroundColor)
163 .mix(color(theme.colors.onSurfaceVariant), 0.12)
164 .rgb()
165 .string();
166 }
167 return color(backgroundColor)
168 .mix(color(theme.colors.onSurfaceVariant), 0)
169 .rgb()
170 .string();
171 }
172
173 if (showSelectedOverlay) {
174 return color(backgroundColor)
175 .mix(color(theme.colors.onSecondaryContainer), 0.12)
176 .rgb()
177 .string();
178 }
179
180 return color(backgroundColor)
181 .mix(color(theme.colors.onSecondaryContainer), 0)
182 .rgb()
183 .string();
184 }
185
186 if (theme.dark) {
187 if (isOutlined) {
188 return color(backgroundColor).lighten(0.2).rgb().string();
189 }
190 return color(backgroundColor).lighten(0.4).rgb().string();
191 }
192
193 if (isOutlined) {
194 return color(backgroundColor).darken(0.08).rgb().string();
195 }
196
197 return color(backgroundColor).darken(0.2).rgb().string();
198};
199

Callers 1

getChipColorsFunction · 0.85

Calls 1

getBackgroundColorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…