Skip to content

Commit

Permalink
fix: missing or duplicated namespaces (#181)
Browse files Browse the repository at this point in the history
* fix: missing or duplicated namespaces
* resolveNamespace to minimal hashFragment
  • Loading branch information
mnapthine authored Mar 27, 2024
1 parent 29b597f commit 8bfcbac
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/stories/UI/tableView.st.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@st-namespace "storiesTableView";

@st-import TableView, [] from "../../TableView/tableView.st.css";

.layoutExample {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/inputAdornment.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@st-namespace "shelleyIcon";
@st-namespace "shelleyInputAdornment";
/**
* = InputAdornment - inputAdornment.st.css
*
Expand Down
1 change: 1 addition & 0 deletions src/styles/mixins/formElements.st.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@st-namespace "formElementsMixin";
/**
* = FORM ELEMENTS - formElements.st.css
*
Expand Down
3 changes: 2 additions & 1 deletion src/styles/mixins/menuList.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* = menuList.st.css. */
@st-namespace "menuListMixin";

@st-import [
--spacing-unit,
--color-focus,
Expand Down
1 change: 1 addition & 0 deletions src/styles/mixins/textVol.st.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@st-namespace "textVolMixin";
/**
* = TEXT MIXIN - /mixins/textVol.st.css
*
Expand Down
1 change: 1 addition & 0 deletions src/styles/notification.st.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@st-namespace "shelleyNotification";
/**
* = Notification - notification.st.css
*
Expand Down
2 changes: 1 addition & 1 deletion src/styles/progressBar.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* progressBar.st.css */
@st-namespace "shelleyProgressBar";
@st-import Shelley, [
--color-ui-rgb-inverse,
--color-ui-rgb,
Expand Down
2 changes: 1 addition & 1 deletion src/styles/progressCircle.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@st-namespace "ShelleyProgressCircle";
@st-namespace "shelleyProgressCircle";

@st-import Shelley, [
--color-ui-rgb,
Expand Down
2 changes: 1 addition & 1 deletion src/styles/project.st.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@st-namespace "shelley";
/**
* Project - Shelley
*
Expand All @@ -7,7 +8,6 @@
* Our Shelley styles set up some sensible defaults for an unbranded project, these
* can be overridden in branded project files.
*/
@st-namespace "shelley";
@st-import [multiply, divide, respScale] from "./formatters/common";

/*=== BUILD-TIME 'VARIABLE' DEFINITIONS ===*/
Expand Down
2 changes: 1 addition & 1 deletion src/styles/radio.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@st-namespace "adio";
@st-namespace "shelleyRadio";
/**
* = Radio - radio.st.css
*
Expand Down
2 changes: 1 addition & 1 deletion src/styles/spacing.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@st-namespace "spacing";
@st-namespace "shelleySpacing";
/**
* = spacing.st.css
*
Expand Down
2 changes: 1 addition & 1 deletion src/styles/visuallyHidden.st.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@st-namespace "visuallyHidden";
@st-namespace "shelleyVisuallyHidden";
/**
* = VisuallyHidden - visuallyHidden.st.css
*
Expand Down
30 changes: 29 additions & 1 deletion stylable.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

const { stcConfig } = require("@stylable/cli");
const { createNamespaceStrategy } = require("@stylable/core");

exports.stcConfig = stcConfig({
options: {
Expand All @@ -9,3 +9,31 @@ exports.stcConfig = stcConfig({
dts: true,
},
});

/**
* Normalizes paths by ensuring they use a consistent separator and potentially
* applying other transformations as needed.
* @param {string} dirPath - The directory path.
* @param {string} filePath - The file path relative to the directory.
* @returns {string} - The normalized path.
*/
function normalizePath(dirPath, filePath) {
// Example: Normalize path separators to forward slashes for consistency
const normalizedDirPath = dirPath.replace(/\\/g, "/");
const normalizedFilePath = filePath.replace(/\\/g, "/");

// Combine and return the normalized path
// This is a simplistic approach; adjust based on your specific needs
return `${normalizedDirPath}/${normalizedFilePath}`;
}

module.exports.defaultConfig = (fs) => {
return {
// set a custom namespace resolver
resolveNamespace: createNamespaceStrategy({
strict: true,
hashFragment: "minimal",
normalizePath: normalizePath,
}),
};
};

0 comments on commit 8bfcbac

Please sign in to comment.