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

Core: Don't persist theme to localStorage #9076

Merged
merged 9 commits into from
Mar 18, 2020
Merged

Conversation

ndelangen
Copy link
Member

Issue: #6798

What I did

The FOUC doesn't happen anymore because of the tri-config api change
I removed the code to prevent the FOUC which was causing other issues.

The FOUC doesn't happen anymore because of the tri-config api change
@ndelangen ndelangen added the bug label Dec 5, 2019
@ndelangen ndelangen added this to the 5.3.0 milestone Dec 5, 2019
@ndelangen ndelangen self-assigned this Dec 5, 2019
@vercel
Copy link

vercel bot commented Dec 5, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/storybook/monorepo/o5s0b60t1
✅ Preview: https://monorepo-git-core-no-persist-theme.storybook.now.sh

@shilman
Copy link
Member

shilman commented Dec 6, 2019

AWESOME. Super excited about this!!!

What happens to users who haven't migrated to the new API?

@ndelangen ndelangen requested a review from shilman December 6, 2019 11:17
@ndelangen
Copy link
Member Author

ndelangen commented Dec 6, 2019

They get the FOUC, seems like a good trade-off to me.

It will nudge them to migrate to the new api I guess.

@shilman
Copy link
Member

shilman commented Dec 6, 2019

Yeah I think that's a fair tradeoff and a great reason to upgrade.

Is there a deprecation warning for the old API, or some other clear path for them to follow when they get the FOUC?

@shilman shilman modified the milestones: 5.3.0, 6.0.0 Dec 20, 2019
@ndelangen ndelangen changed the base branch from next to next-6.0.0 December 20, 2019 23:02
@ndelangen
Copy link
Member Author

@shilman if this is going to be in a major release, is it important enough to get a deprecation warning in?

I looked, and it's not the healthiest code already with multiple layers of deprecated stuff. I'd rather clean it up some more instead.

all this code is already for deprecation warnings:

const deprecationMessage = (optionsMap: OptionsMap, prefix = '') =>
`The options { ${Object.keys(optionsMap).join(', ')} } are deprecated -- use ${
prefix ? `${prefix}'s` : ''
} { ${Object.values(optionsMap).join(', ')} } instead.`;
const applyDeprecatedThemeOptions = deprecate(({ name, url, theme }: Options): PartialThemeVars => {
const { brandTitle, brandUrl, brandImage }: PartialThemeVars = theme || {};
return {
brandTitle: brandTitle || name,
brandUrl: brandUrl || url,
brandImage: brandImage || null,
};
}, deprecationMessage(deprecatedThemeOptions));
const applyDeprecatedLayoutOptions = deprecate((options: Options): PartialLayout => {
const layoutUpdate: PartialLayout = {};
['goFullScreen', 'showStoriesPanel', 'showAddonPanel'].forEach(
(option: 'goFullScreen' | 'showStoriesPanel' | 'showAddonPanel') => {
const v = options[option];
if (typeof v !== 'undefined') {
const key = deprecatedLayoutOptions[option];
layoutUpdate[key] = v;
}
}
);
if (options.addonPanelInRight) {
layoutUpdate.panelPosition = 'right';
}
return layoutUpdate;
}, deprecationMessage(deprecatedLayoutOptions));
const checkDeprecatedThemeOptions = (options: Options) => {
if (Object.keys(deprecatedThemeOptions).find(v => v in options)) {
return applyDeprecatedThemeOptions(options);
}
return {};
};
const checkDeprecatedLayoutOptions = (options: Options) => {
if (Object.keys(deprecatedLayoutOptions).find(v => v in options)) {
return applyDeprecatedLayoutOptions(options);
}
return {};
};

@ndelangen
Copy link
Member Author

Can I remove all that code for 6.0.0?

@shilman
Copy link
Member

shilman commented Dec 21, 2019

@ndelangen Yeah I think we can get rid of that old deprecation warning. If we do, we should mention it in MIGRATION.md for 6.0 and refer back to the original 5.0 notice. cc @tmeasday @Hypnosphi

@stale
Copy link

stale bot commented Jan 30, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jan 30, 2020
@ndelangen ndelangen changed the base branch from next-6.0.0 to next January 30, 2020 09:17
@stale
Copy link

stale bot commented Mar 11, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Mar 11, 2020
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Safe to merge?

@stale stale bot removed the inactive label Mar 11, 2020
@shilman shilman changed the title Do not persist the state.theme to localStorage Core: Don't persist theme to localStorage Mar 11, 2020
@shilman shilman added the core label Mar 11, 2020
@ndelangen ndelangen merged commit 88f2fca into next Mar 18, 2020
@ndelangen ndelangen deleted the core/no-persist-theme branch March 18, 2020 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants