-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vue-demo-store): visibility classes (#545)
* fix(helpers): visibility css classes * fix(vue-demo-store): add visibility classes to safe list * chore: generate changeset * chore: improve code, add tests and fix linter error --------- Co-authored-by: Marc Peternell <[email protected]>
- Loading branch information
Showing
5 changed files
with
98 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"vue-demo-store": minor | ||
"@shopware-pwa/helpers-next": minor | ||
--- | ||
|
||
Fix visibility classes |
68 changes: 68 additions & 0 deletions
68
packages/helpers/src/cms/getCmsLayoutConfiguration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { _getVisibilityClasses } from "./getCmsLayoutConfiguration"; | ||
type FunctionParams = Parameters<typeof _getVisibilityClasses>; | ||
|
||
describe("getVisibilityClasses", () => { | ||
it("should return an empty object if content is a CmsSlot or has no visibility property", () => { | ||
const apiAlias = "cms_slot"; | ||
const content: FunctionParams[0] = { apiAlias }; | ||
const result = _getVisibilityClasses(content); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
it("should return an empty object if content visibility is an empty object", () => { | ||
const apiAlias = "cms_block"; | ||
const content: FunctionParams[0] = { apiAlias, visibility: {} }; | ||
const result = _getVisibilityClasses(content); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
it("should return an empty object if there is no content visibility", () => { | ||
const apiAlias = "cms_block"; | ||
const content: FunctionParams[0] = { apiAlias }; | ||
const result = _getVisibilityClasses(content); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
it("should return the correct visibility CSS classes for tablet", () => { | ||
const apiAlias = "cms_block"; | ||
const content: FunctionParams[0] = { | ||
apiAlias, | ||
visibility: { | ||
mobile: true, | ||
tablet: false, | ||
desktop: true, | ||
}, | ||
}; | ||
const result = _getVisibilityClasses(content); | ||
expect(result).toEqual({ "md:max-lg:hidden": true }); | ||
}); | ||
|
||
it("should return the correct visibility CSS classes for desktop", () => { | ||
const apiAlias = "cms_block"; | ||
const content: FunctionParams[0] = { | ||
apiAlias, | ||
visibility: { | ||
mobile: true, | ||
tablet: true, | ||
desktop: false, | ||
}, | ||
}; | ||
const result = _getVisibilityClasses(content); | ||
expect(result).toEqual({ "lg:hidden": true }); | ||
}); | ||
|
||
it("should return the correct visibility CSS classes for mobile", () => { | ||
const apiAlias = "cms_section"; | ||
const content: FunctionParams[0] = { | ||
apiAlias, | ||
visibility: { | ||
mobile: false, | ||
tablet: true, | ||
desktop: true, | ||
}, | ||
}; | ||
const result = _getVisibilityClasses(content); | ||
expect(result).toEqual({ "max-md:hidden": true }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,4 +113,5 @@ export default defineConfig({ | |
`, | ||
}, | ||
], | ||
safelist: ["max-md:hidden", "md:max-lg:hidden", "lg:hidden"], | ||
}); |
6664aa2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shopware-frontends-docs – ./apps/docs/
shopware-frontends-docs-git-main-shopware-frontends.vercel.app
frontends.shopware.com
shopware-frontends-docs-shopware-frontends.vercel.app
shopware-frontends-docs.vercel.app