Skip to content

Commit

Permalink
remove unused comp tokens
Browse files Browse the repository at this point in the history
Remove component token changes
  • Loading branch information
rlingineni committed Oct 1, 2024
1 parent f9c3b12 commit 852152f
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 852 deletions.
9 changes: 0 additions & 9 deletions packages/gestalt-design-tokens/src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ const filterColor = {
},
};

const filterComponentToken = (component) => ({
'filter': {
'attributes': {
'category': `${component}`,
},
},
});

const filterRounding = {
'filter': {
'attributes': {
Expand Down Expand Up @@ -184,5 +176,4 @@ module.exports = {
filterLineHeight,
filterMotionDuration,
filterMotionEasing,
filterComponentToken,
};
57 changes: 0 additions & 57 deletions packages/gestalt-design-tokens/src/getSources.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,3 @@
const fs = require('fs');

const getListOfComponents = (theme) => {
try {
const folders = fs.readdirSync(`tokens/${theme}/comp`);

const components = folders.filter((file) => !file.includes('.json'));
return components;
} catch (ex) {
// if this fails, it means there are no components
console.log(`No component tokens found for theme ${theme}`);
return [];
}
};

const filterComponentTokenFiles = (theme, components, prefix) =>
components
.map((component) => {
const files = fs.readdirSync(`tokens/${theme}/comp/${component}`);
return files
.filter((file) => file.startsWith(prefix))
.map((file) => `tokens/${theme}/comp/${component}/${file}`);
})
.flat();

/**
* Gets the available files for component tokens
*/
function getComponentTokenSources(platform) {
const theme = 'vr-theme';
const components = getListOfComponents(theme);

const files = filterComponentTokenFiles(theme, components, 'default');

if (platform !== 'web') {
const mobileFiles = filterComponentTokenFiles(theme, components, 'mobile');
files.push(...mobileFiles);
}

return files;
}

/**
* Gets platform-specific component token files
* @param {*} platform - ios, android, web
* @returns
*/
function getComponentTokenOverrides(platform) {
const theme = 'vr-theme';
const components = getListOfComponents(theme);
return filterComponentTokenFiles(theme, components, platform);
}

function getSources({ theme, modeTheme, platform, language }) {
if (theme === 'classic') {
return [
Expand Down Expand Up @@ -85,7 +32,6 @@ function getSources({ theme, modeTheme, platform, language }) {
`tokens/vr-theme/sema/color/${modeTheme}/default.json`,
`tokens/vr-theme/sema/elevation/${modeTheme}.json`,
'tokens/vr-theme/sema/text/font.json',
...getComponentTokenSources(),
...(platform === 'web'
? [
'tokens/vr-theme/base/color/pressed.json',
Expand Down Expand Up @@ -121,7 +67,4 @@ function getSources({ theme, modeTheme, platform, language }) {

module.exports = {
getSources,
getComponentTokenSources,
getComponentTokenOverrides,
getListOfComponents,
};
28 changes: 3 additions & 25 deletions packages/gestalt-design-tokens/src/platforms/android.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getSources, getComponentTokenOverrides, getListOfComponents } = require('../getSources');
const { getSources } = require('../getSources');

const {
filterColor,
Expand All @@ -10,7 +10,6 @@ const {
filterFontWeight,
filterMotionDuration,
filterMotionEasing,
filterComponentToken,
} = require('../filters');

const androidTransformGroup = {
Expand Down Expand Up @@ -43,7 +42,7 @@ const composeObject = {
'_format_comment': 'https://amzn.github.io/style-dictionary/#/formats?id=composeobject',
};

const getFiles = ({ theme, modeTheme, language }) => {
const getFiles = ({ modeTheme, language }) => {
if (modeTheme === 'dark') {
return [
{
Expand All @@ -57,18 +56,6 @@ const getFiles = ({ theme, modeTheme, language }) => {

const files = [];

if (theme === 'vr-theme') {
// add component token files
getListOfComponents(theme).forEach((component) => {
files.push({
'destination': `component/${component}.xml`,
...androidResources,
...dimenResource,
...filterComponentToken(component),
});
});
}

if (language) {
files.push({
'destination': `font-lineheight-${language}.xml`,
Expand Down Expand Up @@ -136,20 +123,11 @@ const getFiles = ({ theme, modeTheme, language }) => {
return files.flat();
};

const getComponentTokenFiles = ({ theme }) => {
if (theme !== 'vr-theme') {
return [];
}

return getComponentTokenOverrides('android');
};

function getAndroidConfiguration({ theme, mode, language }) {
const modeTheme = mode === 'dark' ? 'dark' : 'light';

return {
'include': getSources({ theme, modeTheme, language }),
'source': getComponentTokenFiles({ theme }),
'source': getSources({ theme, modeTheme, language }),
'platforms': {
'android': {
...androidTransformGroup,
Expand Down
34 changes: 3 additions & 31 deletions packages/gestalt-design-tokens/src/platforms/ios.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
const { getFilter } = require('../utils/getFilter');
const {
filterLineHeight,
filterColor,
filterElevation,
filterComponentToken,
} = require('../filters');
const { getSources, getListOfComponents, getComponentTokenOverrides } = require('../getSources');

const toPascal = (str) => str.charAt(0).toUpperCase() + str.slice(1);
const { filterLineHeight, filterColor, filterElevation } = require('../filters');
const { getSources } = require('../getSources');

function getTheme(theme) {
return theme === 'vr-theme' ? 'VR' : '';
Expand Down Expand Up @@ -159,18 +152,6 @@ function getFiles({ theme, modeTheme, language, fileType }) {
});
}

if (theme === 'vr-theme') {
iOSSwiftFiles.push(
...getListOfComponents(theme).map((component) => ({
'destination': `components/GestaltTokens${toPascal(component)}.swift`,
...iosSwiftEnumSwift,
'className': `GestaltTokens${toPascal(component)}`,
...filterComponentToken(component),
fileHeader: `// ${language} specific tokens`,
})),
);
}

if (fileType === 'swift') {
if (modeTheme === 'dark') {
return [
Expand Down Expand Up @@ -230,20 +211,11 @@ function getFiles({ theme, modeTheme, language, fileType }) {
return [];
}

const getComponentTokenFiles = ({ theme }) => {
if (theme !== 'vr-theme') {
return [];
}

return getComponentTokenOverrides('ios');
};

function getIOSConfiguration({ theme, mode, language }) {
const modeTheme = mode === 'dark' ? 'dark' : 'light';

return {
'include': getSources({ theme, modeTheme, language }),
'source': getComponentTokenFiles({ theme }),
'source': getSources({ theme, modeTheme, language }),
'platforms': {
'ios': {
...iOSTransformGroup,
Expand Down
13 changes: 2 additions & 11 deletions packages/gestalt-design-tokens/src/platforms/web.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getSources, getComponentTokenOverrides } = require('../getSources');
const { getSources } = require('../getSources');
const {
dataVisualizationFilter,
colorElevationFilter,
Expand Down Expand Up @@ -138,20 +138,11 @@ const getFiles = ({ theme, modeTheme, language, fileType }) => {
return files.flat();
};

const getComponentTokenFiles = ({ theme }) => {
if (theme === 'classic') {
return [];
}

return getComponentTokenOverrides('web');
};

function getWebConfig({ theme, mode, language }) {
const modeTheme = mode === 'dark' ? 'dark' : 'light';

return {
'include': getSources({ theme, modeTheme, platform: 'web', language }),
'source': getComponentTokenFiles({ theme }),
'source': getSources({ theme, modeTheme, platform: 'web', language }),
'platforms': {
'css': {
...webCssTransformGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,36 +753,6 @@ Object {
<color name=\\"sema_color_dataviz_08\\">#ff400387</color>
<color name=\\"sema_color_dataviz_09\\">#fff2681f</color>
</resources>
",
"dist/android/vr-theme/component/badge.xml": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
<resources>
<dimen name=\\"comp_badge_size_min_height\\">@dimen/sema_space_500</dimen>
<dimen name=\\"comp_badge_size_icon\\">@dimen/sema_space_300</dimen>
<dimen name=\\"comp_badge_space_padding_horizontal\\">@dimen/sema_space_100</dimen>
<dimen name=\\"comp_badge_space_padding_vertical\\">@dimen/sema_space_0</dimen>
<dimen name=\\"comp_badge_space_gap_iconlabel\\">@dimen/sema_space_100</dimen>
<dimen name=\\"comp_badge_rounding\\">@dimen/sema_rounding_100</dimen>
<dimen name=\\"comp_badge_color_background_info\\">@dimen/sema_color_background_info_weak</dimen>
<dimen name=\\"comp_badge_color_background_error\\">@dimen/sema_color_background_error_weak</dimen>
<dimen name=\\"comp_badge_color_background_warning\\">@dimen/sema_color_background_warning_weak</dimen>
<dimen name=\\"comp_badge_color_background_success\\">@dimen/sema_color_background_success_weak</dimen>
<dimen name=\\"comp_badge_color_background_recommendation\\">@dimen/sema_color_background_recommendation_weak</dimen>
<dimen name=\\"comp_badge_color_background_neutral\\">@dimen/sema_color_background_neutral_weak</dimen>
<dimen name=\\"comp_badge_color_background_wash_dark\\">@dimen/sema_color_background_wash_dark</dimen>
<dimen name=\\"comp_badge_color_background_wash_light\\">@dimen/sema_color_background_wash_light</dimen>
<dimen name=\\"comp_badge_color_background_test\\">@dimen/base_color_green_300</dimen>
<dimen name=\\"comp_badge_color_text_info\\">@dimen/sema_color_text_info</dimen>
<dimen name=\\"comp_badge_color_text_error\\">@dimen/sema_color_text_error</dimen>
<dimen name=\\"comp_badge_color_text_warning\\">@dimen/sema_color_text_warning</dimen>
<dimen name=\\"comp_badge_color_text_success\\">@dimen/sema_color_text_success</dimen>
<dimen name=\\"comp_badge_color_text_recommendation\\">@dimen/sema_color_text_recommendation</dimen>
<dimen name=\\"comp_badge_color_text_neutral\\">@dimen/sema_color_text_neutral</dimen>
<dimen name=\\"comp_badge_color_text_wash_dark\\">@dimen/sema_color_text_light</dimen>
<dimen name=\\"comp_badge_color_text_wash_light\\">@dimen/sema_color_text_dark</dimen>
<dimen name=\\"comp_badge_typography_label\\">@dimen/sema_font_size_ui_sm</dimen>
</resources>
",
"dist/android/vr-theme/font-lineheight-ck.xml": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Array [
"dist/android/classic/space.xml",
"dist/android/vr-theme/color-dark.xml",
"dist/android/vr-theme/colors-light.xml",
"dist/android/vr-theme/component/badge.xml",
"dist/android/vr-theme/font-lineheight-ck.xml",
"dist/android/vr-theme/font-lineheight-default.xml",
"dist/android/vr-theme/font-lineheight-ja.xml",
Expand Down Expand Up @@ -179,6 +178,5 @@ Array [
"dist/ios-swift/vr-theme/GestaltTokensOpacityVR.swift",
"dist/ios-swift/vr-theme/GestaltTokensRoundingVR.swift",
"dist/ios-swift/vr-theme/GestaltTokensSpaceVR.swift",
"dist/ios-swift/vr-theme/components/GestaltTokensBadge.swift",
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -1294,39 +1294,6 @@ public enum GestaltTokensSpaceVR {
public static let sema0 = 0px
public static let baseUnit = 4px
}
",
"dist/ios-swift/vr-theme/components/GestaltTokensBadge.swift": "
import SwiftUI
public enum GestaltTokensBadge {
public static let compColorBackgroundTest = baseRed300
public static let compRounding = sema100
public static let compSpaceGapIconlabel = sema100
public static let compSpacePaddingVertical = sema0
public static let compSpacePaddingHorizontal = sema100
public static let compSizeIcon = sema300
public static let compSizeMinHeight = sema500
public static let compTypographyLabel = semaSizeUiSm
public static let compColorTextWashLight = semaTextDark
public static let compColorTextWashDark = semaTextLight
public static let compColorTextNeutral = semaTextNeutral
public static let compColorTextRecommendation = semaTextRecommendation
public static let compColorTextSuccess = semaTextSuccess
public static let compColorTextWarning = semaTextWarning
public static let compColorTextError = semaTextError
public static let compColorTextInfo = semaTextInfo
public static let compColorBackgroundWashLight = semaBackgroundWashLight
public static let compColorBackgroundWashDark = semaBackgroundWashDark
public static let compColorBackgroundNeutral = semaBackgroundNeutralWeak
public static let compColorBackgroundRecommendation = semaBackgroundRecommendationWeak
public static let compColorBackgroundSuccess = semaBackgroundSuccessWeak
public static let compColorBackgroundWarning = semaBackgroundWarningWeak
public static let compColorBackgroundError = semaBackgroundErrorWeak
public static let compColorBackgroundInfo = semaBackgroundInfoWeak
}
",
}
`;
Loading

0 comments on commit 852152f

Please sign in to comment.