This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 814
The Welcome Home Screen: Return Button #9089
Merged
justjanne
merged 16 commits into
develop
from
justjanne/feat/22917-onboarding-return-button
Aug 12, 2022
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
17ba914
Implement button to return to user onboarding screen
justjanne 061b0f1
Merge branch 'develop' into justjanne/feat/22917-onboarding-return-bu…
justjanne 3ebd0ef
Fix copyright header
justjanne c601dce
Add analytics events
justjanne ae9bde5
Merge branch 'develop' into justjanne/feat/22917-onboarding-return-bu…
justjanne 9cc1f18
Merge remote-tracking branch 'origin/develop' into justjanne/feat/229…
justjanne bafc2bf
Merge branch 'develop' into justjanne/feat/22917-onboarding-return-bu…
justjanne a01f9b6
Merge branch 'develop' into justjanne/feat/22917-onboarding-return-bu…
justjanne bcf356d
Merge branch 'develop' into justjanne/feat/22917-onboarding-return-bu…
justjanne 79dc46f
Handle network failures more gracefully
justjanne b0cc9ed
Increase stability of lazy loading test
justjanne 3c4f56a
Merge branch 'develop' into justjanne/feat/22917-onboarding-return-bu…
justjanne 95df0da
Change setting naming
justjanne ab9b652
Merge remote-tracking branch 'origin/develop' into justjanne/feat/229…
justjanne f1b2758
Update test to work with new virtual composer for DMs changes
justjanne 94175ab
Updated i18n
justjanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| .mx_UserOnboardingButton { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-content: stretch; | ||
| align-items: stretch; | ||
| border-radius: 8px; | ||
| margin: $spacing-8 $spacing-8 0; | ||
| padding: $spacing-12; | ||
|
|
||
| &.mx_UserOnboardingButton_selected, | ||
| &:hover, | ||
| &:focus-within { | ||
| background-color: $panel-actions; | ||
| } | ||
|
|
||
| .mx_UserOnboardingButton_content { | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: 5px; | ||
| align-items: center; | ||
|
|
||
| .mx_Heading_h4 { | ||
| margin-right: auto; | ||
| font-size: $font-14px; | ||
| color: $primary-content; | ||
| } | ||
|
|
||
| .mx_UserOnboardingButton_percentage { | ||
| font-size: $font-12px; | ||
| color: $secondary-content; | ||
| } | ||
|
|
||
| .mx_UserOnboardingButton_close { | ||
| position: relative; | ||
| box-sizing: border-box; | ||
| width: 14px; | ||
| height: 14px; | ||
| border-radius: 7px; | ||
| border: 1px solid $secondary-content; | ||
| flex-shrink: 0; | ||
|
|
||
| &::before { | ||
| background-color: $secondary-content; | ||
| content: ""; | ||
| mask-repeat: no-repeat; | ||
| mask-position: center; | ||
| mask-size: contain; | ||
| width: 7px; | ||
| height: 7px; | ||
| position: absolute; | ||
| left: 50%; | ||
| top: 50%; | ||
| transform: translate(-50%, -50%); | ||
| mask-image: url("$(res)/img/element-icons/cancel-rounded.svg"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .mx_ProgressBar { | ||
| width: auto; | ||
| margin-top: $spacing-8; | ||
| background: $background; | ||
| } | ||
|
|
||
| &.mx_UserOnboardingButton_completed .mx_ProgressBar { | ||
| display: none; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/components/views/user-onboarding/UserOnboardingButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import classNames from "classnames"; | ||
| import React, { useCallback } from "react"; | ||
|
|
||
| import { Action } from "../../../dispatcher/actions"; | ||
| import defaultDispatcher from "../../../dispatcher/dispatcher"; | ||
| import { useSettingValue } from "../../../hooks/useSettings"; | ||
| import { useUserOnboardingContext } from "../../../hooks/useUserOnboardingContext"; | ||
| import { useUserOnboardingTasks } from "../../../hooks/useUserOnboardingTasks"; | ||
| import { _t } from "../../../languageHandler"; | ||
| import PosthogTrackers from "../../../PosthogTrackers"; | ||
| import { UseCase } from "../../../settings/enums/UseCase"; | ||
| import { SettingLevel } from "../../../settings/SettingLevel"; | ||
| import SettingsStore from "../../../settings/SettingsStore"; | ||
| import AccessibleButton, { ButtonEvent } from "../../views/elements/AccessibleButton"; | ||
| import ProgressBar from "../../views/elements/ProgressBar"; | ||
| import Heading from "../../views/typography/Heading"; | ||
| import { showUserOnboardingPage } from "./UserOnboardingPage"; | ||
|
|
||
| function toPercentage(progress: number): string { | ||
| return (progress * 100).toFixed(0); | ||
| } | ||
|
|
||
| interface Props { | ||
| selected: boolean; | ||
| minimized: boolean; | ||
| } | ||
|
|
||
| export function UserOnboardingButton({ selected, minimized }: Props) { | ||
| const context = useUserOnboardingContext(); | ||
| const [completedTasks, waitingTasks] = useUserOnboardingTasks(context); | ||
|
|
||
| const completed = completedTasks.length; | ||
| const waiting = waitingTasks.length; | ||
| const total = completed + waiting; | ||
|
|
||
| let progress = 1; | ||
| if (context && waiting) { | ||
| progress = completed / total; | ||
| } | ||
|
|
||
| const onDismiss = useCallback((ev: ButtonEvent) => { | ||
| PosthogTrackers.trackInteraction("WebRoomListUserOnboardingIgnoreButton", ev); | ||
| SettingsStore.setValue("FTUE.userOnboardingButton", null, SettingLevel.ACCOUNT, false); | ||
| }, []); | ||
|
|
||
| const onClick = useCallback((ev: ButtonEvent) => { | ||
| PosthogTrackers.trackInteraction("WebRoomListUserOnboardingButton", ev); | ||
| defaultDispatcher.fire(Action.ViewHomePage); | ||
| }, []); | ||
|
|
||
| const useCase = useSettingValue<UseCase | null>("FTUE.useCaseSelection"); | ||
| const visible = useSettingValue<boolean>("FTUE.userOnboardingButton"); | ||
| if (!visible || minimized || !showUserOnboardingPage(useCase)) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <AccessibleButton | ||
| className={classNames("mx_UserOnboardingButton", { | ||
| "mx_UserOnboardingButton_selected": selected, | ||
| "mx_UserOnboardingButton_minimized": minimized, | ||
| "mx_UserOnboardingButton_completed": !waiting || !context, | ||
| })} | ||
| onClick={onClick}> | ||
| { !minimized && ( | ||
| <> | ||
| <div className="mx_UserOnboardingButton_content"> | ||
| <Heading size="h4" className="mx_Heading_h4"> | ||
| { _t("Welcome") } | ||
| </Heading> | ||
| { context && !completed && ( | ||
| <div className="mx_UserOnboardingButton_percentage"> | ||
| { toPercentage(progress) }% | ||
| </div> | ||
| ) } | ||
| <AccessibleButton | ||
| className="mx_UserOnboardingButton_close" | ||
| onClick={onDismiss} | ||
| /> | ||
| </div> | ||
| <ProgressBar value={completed} max={total} animated /> | ||
| </> | ||
| ) } | ||
| </AccessibleButton> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.