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

Make app loader on top bar smaller #3034

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions webapp/components/Spinner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
import { CircularProgress } from '@mui/material'

export const Spinner = (props) => {
const { size } = props

return <CircularProgress size={size} />
}

Spinner.propTypes = {
size: PropTypes.number,
}

Spinner.defaultProps = {
size: 40,
}
1 change: 1 addition & 0 deletions webapp/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ export { RadioButtonGroup } from './RadioButtonGroup'
export { ResizableModal } from './ResizableModal'
export { Slider } from './Slider'
export { Split } from './Split'
export { Spinner } from './Spinner'
48 changes: 23 additions & 25 deletions webapp/views/App/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { TestId } from '@webapp/utils/testId'

import { appModuleUri, homeModules } from '@webapp/app/appModules'

import { Spinner } from '@webapp/components'
import { usePrevious } from '@webapp/components/hooks'
import ProfilePicture from '@webapp/components/profilePicture'
import ProgressBar from '@webapp/components/progressBar'
import ButtonPublishSurvey from '@webapp/components/buttonPublishSurvey'
import { LabelWithTooltip } from '@webapp/components/form/LabelWithTooltip'
import { SurveyPreferredLanguageSelector } from '@webapp/components/survey/SurveyPreferredLanguageSelector'
Expand Down Expand Up @@ -61,30 +61,28 @@ const Header = () => {
<Breadcrumbs />

<div className="header__survey">
{Survey.isValid(surveyInfo) &&
(appSaving ? (
<ProgressBar className="progress-bar-striped" progress={100} showText={false} />
) : (
<>
<Link
data-testid={TestId.header.surveyTitle}
to={appModuleUri(homeModules.surveyInfo)}
className="btn-s btn-transparent"
>
<LabelWithTooltip className="header__survey-title" label={surveyTitle} />
</Link>
<CycleSelector
selectedCycle={surveyCycleKey}
onChange={(cycle) => {
const surveyId = Survey.getIdSurveyInfo(surveyInfo)
const userUpdated = User.assocPrefSurveyCycle(surveyId, cycle)(user)
dispatch(UserActions.updateUserPrefs({ user: userUpdated }))
}}
/>
<SurveyPreferredLanguageSelector />
{canEditSurvey && Survey.isDraft(surveyInfo) && <ButtonPublishSurvey className="btn-secondary" />}
</>
))}
{Survey.isValid(surveyInfo) && (
<>
<Link
data-testid={TestId.header.surveyTitle}
to={appModuleUri(homeModules.surveyInfo)}
className="btn-s btn-transparent"
>
<LabelWithTooltip className="header__survey-title" label={surveyTitle} />
</Link>
<CycleSelector
selectedCycle={surveyCycleKey}
onChange={(cycle) => {
const surveyId = Survey.getIdSurveyInfo(surveyInfo)
const userUpdated = User.assocPrefSurveyCycle(surveyId, cycle)(user)
dispatch(UserActions.updateUserPrefs({ user: userUpdated }))
}}
/>
<SurveyPreferredLanguageSelector />
{canEditSurvey && Survey.isDraft(surveyInfo) && <ButtonPublishSurvey className="btn-secondary" />}
<div className="header__loader-wrapper">{appSaving && <Spinner size={25} />}</div>
</>
)}
</div>

{/* Placeholder to make the header symmetric */}
Expand Down
7 changes: 7 additions & 0 deletions webapp/views/App/Header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
line-height: normal;
}

.header__loader-wrapper {
display: flex;
align-items: center;
width: 3rem;
margin-left: 10px;
}

.header__btn-user {
max-height: $headerHeight - 1px;
margin-right: 20px;
Expand Down