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

Export themes from brand center #6573

Open
StfBauer opened this issue Jan 23, 2025 · 3 comments
Open

Export themes from brand center #6573

StfBauer opened this issue Jan 23, 2025 · 3 comments
Labels
feature request needs peer review Needs second pair of eyes to review the spec or PR

Comments

@StfBauer
Copy link
Contributor

Theme Center has an API to export the theme that has been directly created in the Brand Center.

https://<tenant>.sharepoint.com/sites/brandcenter/_api/brandcenter/GetTenantThemes

This call will return all a theme in the following format:

{
    "@odata.context": "https://contoso.sharepoint.com/sites/brandcenter/_api/$metadata#SP.TenantThemes",
    "hideDefaultThemes": false,
    "themeData": [
        {
            "id": 83,
            "isThemesV2": false,
            "isVisible": true,
            "name": "Coffee Theme",
            "source": 1,
            "themeJson": "{\"name\":\"Coffee Theme\",\"isInverted\":true,\"palette\":{\"themeDarker\":\"#171f1d\",\"themeDark\":\"#2c3b37\",\"themeDarkAlt\":\"#415751\",\"themePrimary\":\"#C0FFEE\",\"themeSecondary\":\"#56736b\",\"themeTertiary\":\"#6b8f85\",\"themeLight\":\"#80ab9f\",\"themeLighter\":\"#95c7ba\",\"themeLighterAlt\":\"#aae3d4\",\"black\":\"#171f1d\",\"neutralDark\":\"#2c3b37\",\"neutralPrimary\":\"#C0FFEE\",\"neutralPrimaryAlt\":\"#56736b\",\"neutralSecondary\":\"#6b8f85\",\"neutralTertiary\":\"#80ab9f\",\"neutralTertiaryAlt\":\"#000000\",\"neutralLight\":\"#000000\",\"neutralLighter\":\"#000000\",\"neutralLighterAlt\":\"#000000\",\"white\":\"#000000\",\"neutralQuaternaryAlt\":\"#000000\",\"neutralQuaternary\":\"#000000\",\"accent\":\"#4F6BED\"}}"
        }
    ]
}

This call returns all the themes.

m365 spo theme list

This does not return any of the Brand Center specifc themes so either we should include these calls in the regular command or write a dedicated set of Brand Center calls. Thoughts?

@waldekmastykarz
Copy link
Member

Makes perfect sense to include brand center themes in there.

We have the following options:

  1. Introduce a new command for it
  2. Extend spo theme list to include BC themes, add a switch to exclude, eg. --withoutBrandCentral
  3. Extend spo theme list with a switch to include BC themes, eg. --withBrandCentral

My gut feeling tells me to go with 2 but I'm curious what you think @pnp/cli-for-microsoft-365-maintainers

@waldekmastykarz waldekmastykarz added needs peer review Needs second pair of eyes to review the spec or PR feature request labels Jan 23, 2025
@StfBauer
Copy link
Contributor Author

Turns out the api can get called from everywhere in SharePoint with that URL and does not need to get called within brand center.

In addition we have other brand center specific methods:

AddTenantTheme

Endpoint:

/_api/brandcenter/AddTenantTheme

Payload:

{
    "themeData": {
        "name": "Test",
        "themeJson": "{\"name\":\"Test\",\"isInverted\":true,\"palette\":{\"themeDarker\":\"#014446\",\"themeDark\":\"#025c5f\",\"themeDarkAlt\":\"#026d70\",\"themePrimary\":\"#03787C\",\"themeSecondary\":\"#13898d\",\"themeTertiary\":\"#49aeb1\",\"themeLight\":\"#98d6d8\",\"themeLighter\":\"#c5e9ea\",\"themeLighterAlt\":\"#f0f9fa\",\"black\":\"#000000\",\"neutralDark\":\"#201f1e\",\"neutralPrimary\":\"#323130\",\"neutralPrimaryAlt\":\"#3b3a39\",\"neutralSecondary\":\"#605e5c\",\"neutralTertiary\":\"#a19f9d\",\"neutralTertiaryAlt\":\"#c8c6c4\",\"neutralLight\":\"#edebe9\",\"neutralLighter\":\"#f3f2f1\",\"neutralLighterAlt\":\"#faf9f8\",\"white\":\"#ffffff\",\"neutralQuaternaryAlt\":\"#e1dfdd\",\"neutralQuaternary\":\"#d0d0d0\",\"accent\":\"#C0FFEE\"}}",
        "isVisible": true,
        "source": 1
    }
}

UpdateTenantTheme

Endpoint

/_api/brandcenter/UpdateTenantTheme

Payload

{
    "themeData": {
        "id": "83",
        "name": "Coffee Theme",
        "themeJson": "{\"name\":\"Coffee Theme\",\"isInverted\":true,\"palette\":{\"themeDarker\":\"#171f1d\",\"themeDark\":\"#2c3b37\",\"themeDarkAlt\":\"#415751\",\"themePrimary\":\"#C0FFEE\",\"themeSecondary\":\"#56736b\",\"themeTertiary\":\"#6b8f85\",\"themeLight\":\"#80ab9f\",\"themeLighter\":\"#95c7ba\",\"themeLighterAlt\":\"#aae3d4\",\"black\":\"#171f1d\",\"neutralDark\":\"#2c3b37\",\"neutralPrimary\":\"#C0FFEE\",\"neutralPrimaryAlt\":\"#56736b\",\"neutralSecondary\":\"#6b8f85\",\"neutralTertiary\":\"#80ab9f\",\"neutralTertiaryAlt\":\"#000000\",\"neutralLight\":\"#000000\",\"neutralLighter\":\"#000000\",\"neutralLighterAlt\":\"#000000\",\"white\":\"#000000\",\"neutralQuaternaryAlt\":\"#000000\",\"neutralQuaternary\":\"#000000\",\"accent\":\"#4F6BED\"}}",
        "isVisible": true,
        "source": 1
    }
}

Validate Theme Name

Endpoint

_api/brandcenter/ValidateTenantThemeName

Payload:

{"name":"Test"}

@martinlingstuyl
Copy link
Contributor

Interesting @StfBauer, @waldekmastykarz. I agree it would be best to go with option 2; include the results from the extra api call on the existing theme list command.

Question though: do you have an idea what the source property means that's included in the response object? Could it be an enum of which nr 1 means brandcenter theme? (0 being regular tenant themes) That would be an interesting perspective that could maybe help us out here: if my assumption is correct we could add a --source option with several auto completed options like: all, regular, brandcenter, or something like it.

For adding and updating themes we should look into the same principle: adding the functionality to existing commands spo theme add and set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request needs peer review Needs second pair of eyes to review the spec or PR
Projects
None yet
Development

No branches or pull requests

3 participants