Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support stylesheets for BYOC Unwrapped and SXA Components #1722

Merged
merged 12 commits into from
Jan 26, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Our versioning strategy is as follows:
* `[nextjs/template]` `[sitecore-jss-nextjs]` On-demand ISR [#1674](https://github.com/Sitecore/jss/pull/1674))
* `[sitecore-jss]` `[templates/nextjs-xmcloud]` Load the content styles for the RichText component ([#1670](https://github.com/Sitecore/jss/pull/1670))([#1683](https://github.com/Sitecore/jss/pull/1683)) ([#1684](https://github.com/Sitecore/jss/pull/1684)) ([#1693](https://github.com/Sitecore/jss/pull/1693))
* `[templates/react]` `[sitecore-jss-react]` Replace package 'deep-equal' with 'fast-deep-equal'. No functionality change only performance improvement ([#1719](https://github.com/Sitecore/jss/pull/1719)) ([#1665](https://github.com/Sitecore/jss/pull/1665))
* `[templates/nextjs-xmcloud]` `[sitecore-jss]` `[sitecore-jss-nextjs]` `[sitecore-react]` Add support for loading appropriate stylesheets whenever a theme is applied to BYOC and SXA components by introducing new function getComponentLibraryStylesheetLinks, which replaces getFEAASLibraryStylesheetLinks (which has been marked as deprecated) ([#1722](https://github.com/Sitecore/jss/pull/1722))
yavorsk marked this conversation as resolved.
Show resolved Hide resolved

### 🐛 Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { SitecorePageProps } from 'lib/page-props';
import { getFEAASLibraryStylesheetLinks } from '@sitecore-jss/sitecore-jss-nextjs';
import { getComponentLibraryStylesheetLinks } from '@sitecore-jss/sitecore-jss-nextjs';
import { Plugin } from '..';
import config from 'temp/config';

class FEeaSThemesPlugin implements Plugin {
class ComponentThemesPlugin implements Plugin {
order = 2;

async exec(props: SitecorePageProps) {
// Collect FEAAS themes
// Collect FEAAS, BYOC, SXA component themes
props.headLinks.push(
...getFEAASLibraryStylesheetLinks(
...getComponentLibraryStylesheetLinks(
props.layoutData,
config.sitecoreEdgeContextId,
config.sitecoreEdgeUrl
Expand All @@ -19,4 +19,4 @@ class FEeaSThemesPlugin implements Plugin {
}
}

export const feaasThemesPlugin = new FEeaSThemesPlugin();
export const componentThemesPlugin = new ComponentThemesPlugin();
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export {
BYOCComponent,
BYOCComponentProps,
getFEAASLibraryStylesheetLinks,
getComponentLibraryStylesheetLinks,
File,
FileField,
RichTextField,
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export {
} from '@sitecore-jss/sitecore-jss/i18n';
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
export { getFEAASLibraryStylesheetLinks } from '@sitecore-jss/sitecore-jss/feaas';
export { getComponentLibraryStylesheetLinks } from '@sitecore-jss/sitecore-jss/layout';
yavorsk marked this conversation as resolved.
Show resolved Hide resolved
export { ComponentFactory } from './components/sharedTypes';
export { Placeholder, PlaceholderComponentProps } from './components/Placeholder';
export {
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss/src/feaas/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const FEAAS_LIBRARY_ID_REGEX = /-library--([^\s]+)/;
* @param {string} sitecoreEdgeContextId Sitecore Edge Context ID
* @param {string} [sitecoreEdgeUrl] Sitecore Edge Platform URL. Default is https://edge-platform.sitecorecloud.io
* @returns {HTMLLink[]} library stylesheet links
* @deprecated use getComponentLibraryStylesheetLinks instead; getFEAASLibraryStylesheetLinks will be removed in v22.0
*/
export function getFEAASLibraryStylesheetLinks(
layoutData: LayoutServiceData,
Expand Down
2 changes: 2 additions & 0 deletions packages/sitecore-jss/src/layout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ export {
} from './rest-layout-service';

export { GraphQLLayoutService, GraphQLLayoutServiceConfig } from './graphql-layout-service';

export { getComponentLibraryStylesheetLinks } from './themes';
Loading