Skip to content

Commit

Permalink
use private prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Dec 2, 2022
1 parent 4e84477 commit 73c11f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
10 changes: 5 additions & 5 deletions packages/mui-material/src/styles/experimental_extendTheme.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { deepmerge } from '@mui/utils';
import {
safeColorChannel,
safeAlpha,
safeDarken,
safeLighten,
safeEmphasize,
private_safeColorChannel as safeColorChannel,
private_safeAlpha as safeAlpha,
private_safeDarken as safeDarken,
private_safeLighten as safeLighten,
private_safeEmphasize as safeEmphasize,
unstable_createGetCssVar as systemCreateGetCssVar,
} from '@mui/system';
import createThemeWithoutVars from './createTheme';
Expand Down
15 changes: 10 additions & 5 deletions packages/mui-system/src/colorManipulator.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
export type ColorFormat = 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'color';
export interface ColorObject {
type: ColorFormat;
Expand All @@ -10,15 +11,19 @@ export function rgbToHex(color: string): string;
export function hslToRgb(color: string): string;
export function decomposeColor(color: string): ColorObject;
export function colorChannel(color: string): string;
export function safeColorChannel(color: string, warning?: string): string;
export function private_safeColorChannel(color: string, warning?: string): string;
export function recomposeColor(color: ColorObject): string;
export function getContrastRatio(foreground: string, background: string): number;
export function getLuminance(color: string): number;
export function emphasize(color: string, coefficient?: number): string;
export function safeEmphasize(color: string, coefficient?: number, warning?: string): string;
export function private_safeEmphasize(
color: string,
coefficient?: number,
warning?: string,
): string;
export function alpha(color: string, value: number): string;
export function safeAlpha(color: string, value: number, warning?: string): string;
export function private_safeAlpha(color: string, value: number, warning?: string): string;
export function darken(color: string, coefficient: number): string;
export function safeDarken(color: string, coefficient: number, warning?: string): string;
export function private_safeDarken(color: string, coefficient: number, warning?: string): string;
export function lighten(color: string, coefficient: number): string;
export function safeLighten(color: string, coefficient: number, warning?: string): string;
export function private_safeLighten(color: string, coefficient: number, warning?: string): string;
13 changes: 7 additions & 6 deletions packages/mui-system/src/colorManipulator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
import MuiError from '@mui/utils/macros/MuiError.macro';

/**
Expand Down Expand Up @@ -111,7 +112,7 @@ export const colorChannel = (color) => {
.map((val, idx) => (decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val))
.join(' ');
};
export const safeColorChannel = (color, warning) => {
export const private_safeColorChannel = (color, warning) => {
try {
return colorChannel(color);
} catch (error) {
Expand Down Expand Up @@ -250,7 +251,7 @@ export function alpha(color, value) {

return recomposeColor(color);
}
export function safeAlpha(color, value, warning) {
export function private_safeAlpha(color, value, warning) {
try {
return alpha(color, value);
} catch (error) {
Expand Down Expand Up @@ -280,7 +281,7 @@ export function darken(color, coefficient) {
}
return recomposeColor(color);
}
export function safeDarken(color, coefficient, warning) {
export function private_safeDarken(color, coefficient, warning) {
try {
return darken(color, coefficient);
} catch (error) {
Expand Down Expand Up @@ -315,7 +316,7 @@ export function lighten(color, coefficient) {

return recomposeColor(color);
}
export function safeLighten(color, coefficient, warning) {
export function private_safeLighten(color, coefficient, warning) {
try {
return lighten(color, coefficient);
} catch (error) {
Expand All @@ -336,9 +337,9 @@ export function safeLighten(color, coefficient, warning) {
export function emphasize(color, coefficient = 0.15) {
return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
}
export function safeEmphasize(color, coefficient, warning) {
export function private_safeEmphasize(color, coefficient, warning) {
try {
return safeEmphasize(color, coefficient);
return private_safeEmphasize(color, coefficient);
} catch (error) {
if (warning && process.env.NODE_ENV !== 'production') {
console.warn(warning);
Expand Down

0 comments on commit 73c11f3

Please sign in to comment.