Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { adminTheme, Background } from '@codecademy/gamut-styles';

import { Code, ColorScale, TokenTable } from '~styleguide/blocks';

import { applyCorrectNotation } from './applyCorrectNotation';
import { PATH_COLUMN, PROP_COLUMN } from './elements';

export const adminLightMode = {
Expand All @@ -13,7 +14,9 @@ export const adminLightMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand All @@ -39,7 +42,9 @@ export const adminDarkMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const applyCorrectNotation = ({ id }: { id: string }) => {
const hasHypen = id.includes('-');
if (!hasHypen) return `.${id}`;
return `['${id}']`;
};
22 changes: 16 additions & 6 deletions packages/styleguide/src/lib/Foundations/shared/elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import kebabCase from 'lodash/kebabCase';

import { Code, ColorScale, LinkTo, TokenTable } from '~styleguide/blocks';

import { applyCorrectNotation } from './applyCorrectNotation';

export const PROP_COLUMN = {
key: 'key',
name: 'Prop',
Expand Down Expand Up @@ -41,7 +43,9 @@ export const lightMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand All @@ -67,7 +71,9 @@ export const darkMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand All @@ -91,7 +97,9 @@ export const color = {
PROP_COLUMN,
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand All @@ -117,7 +125,7 @@ export const swatch = {
render: ({ id, hexes }: any) => {
return (
<Code>
theme.colors[`{id}-{Object.keys(hexes)[0]}`]
theme.colors[&apos;{id}-{Object.keys(hexes)[0]}&apos;]
</Code>
);
},
Expand Down Expand Up @@ -145,7 +153,7 @@ export const rgbaSwatch = {
render: ({ id, hexes }: any) => {
return (
<Code>
theme.colors[`{id}-{Object.keys(hexes)[0]}`]
theme.colors[&apos;{id}-{Object.keys(hexes)[0]}&apos;]
</Code>
);
},
Expand Down Expand Up @@ -195,7 +203,9 @@ export const lxStudioColor = {
PROP_COLUMN,
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

import { Code, ColorScale, TokenTable } from '~styleguide/blocks';

import { applyCorrectNotation } from './applyCorrectNotation';
import {
createExampleColumn,
PATH_COLUMN,
Expand All @@ -23,7 +24,9 @@ export const lxStudioColor = {
PROP_COLUMN,
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand All @@ -43,7 +46,9 @@ export const lxStudioLightMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand Down Expand Up @@ -71,7 +76,9 @@ export const lxStudioDarkMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

import { Code, ColorScale, TokenTable } from '~styleguide/blocks';

import { applyCorrectNotation } from './applyCorrectNotation';
import { PATH_COLUMN, PROP_COLUMN } from './elements';

export const platformSwatch = {
Expand All @@ -20,7 +21,7 @@ export const platformSwatch = {
...PATH_COLUMN,
render: ({ id, hexes }: any) => (
<Code>
theme.colors[`{id}-{Object.keys(hexes)[0]}`]
theme.colors[&apos;{id}-{Object.keys(hexes)[0]}&apos;]
</Code>
),
},
Expand All @@ -44,7 +45,9 @@ export const platformColor = {
PROP_COLUMN,
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand All @@ -64,7 +67,9 @@ export const platformLightMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand Down Expand Up @@ -92,7 +97,9 @@ export const platformDarkMode = {
{ ...PROP_COLUMN, size: 'lg' },
{
...PATH_COLUMN,
render: ({ id }: any) => <Code>theme.colors.{id}</Code>,
render: ({ id }: any) => (
<Code>theme.colors{applyCorrectNotation({ id })}</Code>
),
},
{
key: 'swatch',
Expand Down
Loading