mi6 / ic-design-system

Intelligence Community Design System
https://design.sis.gov.uk
MIT License
36 stars 27 forks source link

Persist a user's chosen language and framework for code demos #817

Open GCHQ-Developer-112 opened 5 months ago

GCHQ-Developer-112 commented 5 months ago

Summary

Add a functional cookie to local storage that stores a user's chosen language and framework. When the Javascript/Typescript toggle button is added to the ComponentPreview component, users, in particular React users, will have to take additional steps to select their chosen framework and language (depending on the default language). By saving their preference in a cookie, we can improve their user experience and ensure they always see code examples in their chosen framework and language.

💰 User value

This will improve the user experience as users will not have to constantly switch to their preferred coding framework and language.

📝 Acceptance Criteria

Given I am a developer using the ICDS guidance site, When I select my preferred framework (and language if applicable) in a code demo Then I should see all future code demos in the framework (and language if applicable)

Given I am a developer using the ICDS guidance site, And I have previously selected my preferred framework (and language if applicable) in a code demo When I change my preferred framework (and language if applicable) in a code demo Then I should see all future code demos in the newly selected framework (and language if applicable)

MI6-255 commented 2 months ago

Consider if we use cookies (but would need to implement a way to have essential cookies in settings) or local storage