Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(styles) deprecate space export and add space to theme #75790

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
9 changes: 7 additions & 2 deletions static/app/styles/space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ const SPACES = {

export type ValidSize = keyof typeof SPACES;

function space<S extends ValidSize>(size: S): (typeof SPACES)[S] {
/**
* @deprecated You can now access space directly inside styled template literals via p => p.theme.space(value) or inside your component body via const {space} = useTheme();
*/
export function space<S extends ValidSize>(size: S): (typeof SPACES)[S] {
return SPACES[size];
}

export {space};
export function themeSpace<S extends ValidSize>(size: S): (typeof SPACES)[S] {
return SPACES[size];
}
3 changes: 3 additions & 0 deletions static/app/utils/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import color from 'color';

import {DATA_CATEGORY_INFO} from 'sentry/constants';
import {CHART_PALETTE} from 'sentry/constants/chartPalette';
import {themeSpace} from 'sentry/styles/space';
import {Outcome} from 'sentry/types/core';

const lightColors = {
Expand Down Expand Up @@ -958,6 +959,7 @@ export const lightTheme = {
...darkColors,
...darkAliases,
},
space: themeSpace,
...generateUtils(lightColors, lightAliases),
alert: generateAlertTheme(lightColors, lightAliases),
badge: generateBadgeTheme(lightColors),
Expand Down Expand Up @@ -986,6 +988,7 @@ export const darkTheme: Theme = {
...lightColors,
...lightAliases,
},
space: themeSpace,
...generateUtils(darkColors, lightAliases),
alert: generateAlertTheme(darkColors, darkAliases),
badge: generateBadgeTheme(darkColors),
Expand Down
Loading