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

feat: Wire up design settings (theme colour & logo) #2660

Merged
merged 7 commits into from
Jan 17, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Jan 12, 2024

What does this PR do?

  • Split up DesignSettings component into reusable components
  • Wire up theme and logo form. This PR is primarily concerned with updating values in DB and primaryColour in theme, but is implemented throughout the application consistently in feat: Apply theme colours across app #2658
  • SHOW_TEAM_SETTINGS feature flag still required

To test

  • I can update theme colour
  • I can update logo
  • Preview is "live" and works as expected
  • "Reset" button works as expected

image

Copy link

github-actions bot commented Jan 12, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr force-pushed the dp/wire-up-team-design-form branch from ef44ac5 to 3234a3c Compare January 12, 2024 16:10
@DafyddLlyr DafyddLlyr force-pushed the dp/wire-up-team-design-form branch 2 times, most recently from 1cff2e6 to efa2225 Compare January 15, 2024 09:55
@DafyddLlyr DafyddLlyr changed the base branch from main to dp/add-client-to-store January 15, 2024 09:59
@DafyddLlyr DafyddLlyr force-pushed the dp/wire-up-team-design-form branch from efa2225 to caada89 Compare January 15, 2024 10:01
@DafyddLlyr DafyddLlyr force-pushed the dp/add-client-to-store branch from 690e931 to 8a01411 Compare January 15, 2024 10:20
@DafyddLlyr DafyddLlyr force-pushed the dp/wire-up-team-design-form branch from caada89 to 28b192c Compare January 15, 2024 10:21
@DafyddLlyr DafyddLlyr force-pushed the dp/add-client-to-store branch from 8a01411 to 15b47a4 Compare January 15, 2024 10:29
DafyddLlyr added a commit to theopensystemslab/planx-core that referenced this pull request Jan 15, 2024
## What does this PR do?
- Adds new `team.updateTheme()` method
- Implemented in
theopensystemslab/planx-new#2660
@DafyddLlyr DafyddLlyr force-pushed the dp/wire-up-team-design-form branch from 28b192c to 958a633 Compare January 15, 2024 10:43
@DafyddLlyr DafyddLlyr force-pushed the dp/add-client-to-store branch from 15b47a4 to bfa2fc4 Compare January 15, 2024 15:39
Base automatically changed from dp/add-client-to-store to main January 16, 2024 15:33
@DafyddLlyr DafyddLlyr force-pushed the dp/wire-up-team-design-form branch from 958a633 to b81cbb5 Compare January 16, 2024 15:43
@DafyddLlyr DafyddLlyr changed the title feat(wip): Wire up design settings (theme colour & logo) feat: Wire up design settings (theme colour & logo) Jan 16, 2024
Comment on lines 22 to 32
useEffect(() => {
setInitialValues({
primaryColour: team.theme?.primaryColour,
logo: team.theme?.logo,
})
}, [team])

const [initialValues, setInitialValues] = useState<FormValues>({
primaryColour: "",
logo: "",
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels a bit awkward but was the best way I could get the form to handle async initial values from outside the component. Without this the form reverted to its initial state on reset (even after a successful "Save").

useEffect(() => {
const fetchTeam = async () => {
try {
const fetchedTeam = await useStore.getState().fetchCurrentTeam();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to get the team from the DB as the currently held team in the store does not include the theme. If we fetch the theme initially, it's them live throughout the Editor (e.g. the header changes colour when navigating from team to team).

This could be resolved and simplified, I'll either revist as another PR or open an issue.

Comment on lines +123 to +125
<ButtonForm />
<TextLinkForm />
<FaviconForm />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ButtonForm, FaviconForm and TextLinkForm are currently still placeholders are will be wired up in follow-up PR sbranched from this one. The current PR is big enough as is!

@DafyddLlyr DafyddLlyr marked this pull request as ready for review January 16, 2024 17:07
@DafyddLlyr DafyddLlyr requested a review from a team January 16, 2024 17:07
<ButtonForm />
<TextLinkForm />
<FaviconForm />
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we're happy with this approach of using Snackbar within the Editor for notifications we might want to move this to a higher level and set up a service to call it in various child components as opposed to repeating it in multiple places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Snackbar works really well in this scenario!

@DafyddLlyr
Copy link
Contributor Author

@DafyddLlyr
Copy link
Contributor Author

Copy link
Contributor

@Mike-Heneghan Mike-Heneghan left a comment

Choose a reason for hiding this comment

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

Looks great and working as expected for me 👍

@DafyddLlyr DafyddLlyr merged commit 6fe38c4 into main Jan 17, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/wire-up-team-design-form branch January 17, 2024 16:34
@DafyddLlyr DafyddLlyr restored the dp/wire-up-team-design-form branch January 17, 2024 16:34
@DafyddLlyr DafyddLlyr deleted the dp/wire-up-team-design-form branch January 17, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants