Skip to content

Commit

Permalink
ref(styles) deprecate space export and add space to theme
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Aug 7, 2024
1 parent c661185 commit 6a0bb31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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 useTheme().space
*/
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';

const lightColors = {
Expand Down Expand Up @@ -941,6 +942,7 @@ export const lightTheme = {
...darkColors,
...darkAliases,
},
space: themeSpace,
...generateUtils(lightColors, lightAliases),
alert: generateAlertTheme(lightColors, lightAliases),
badge: generateBadgeTheme(lightColors),
Expand Down Expand Up @@ -969,6 +971,7 @@ export const darkTheme: Theme = {
...lightColors,
...lightAliases,
},
space: themeSpace,
...generateUtils(darkColors, lightAliases),
alert: generateAlertTheme(darkColors, darkAliases),
badge: generateBadgeTheme(darkColors),
Expand Down

0 comments on commit 6a0bb31

Please sign in to comment.