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

Fix: align right header items #1720

Merged
merged 4 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 9 additions & 1 deletion src/app/views/authentication/Authentication.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ export const authenticationStyles = (theme: ITheme) => {
alignItems: 'flex-start',
justifyContent: 'start',
marginRight: theme.spacing.s1,
padding: theme.spacing.s1
padding: theme.spacing.s1,
position: 'relative',
top: '1px'
},
spinnerContainer: {
display: 'flex',
flexDirection: 'row'
},
loginProgressLabelStyles: {
root: {
position: 'relative',
top: '6px'
}
}
};
};
2 changes: 1 addition & 1 deletion src/app/views/authentication/Authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Authentication = (props: any) => {
<div className={classes.spinnerContainer}>
<Spinner className={classes.spinner} size={SpinnerSize.medium} />
{!minimised && (
<Label>
<Label styles={{ root: { position: 'relative', top: '8px'}}} >
<FormattedMessage
id={`Signing you ${loginInProgress ? 'in' : 'out'}...`}
/>
Expand Down
6 changes: 6 additions & 0 deletions src/app/views/authentication/profile/Profile.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export const profileStyles = (theme: ITheme) => {
paddingBottom: 10,
textTransform: 'lowercase'
}
},
profileSpinnerStyles: {
root: {
position: 'relative' as 'relative',
top: '2px'
}
}
}
}
3 changes: 2 additions & 1 deletion src/app/views/authentication/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const Profile = (props: any) => {
const theme = getTheme();
const linkStyles = profileStyles(theme).linkStyles
const personaStyleToken = profileStyles(theme).personaStyleToken;
const profileSpinnerStyles = profileStyles(theme).profileSpinnerStyles;


useEffect(() => {
Expand All @@ -85,7 +86,7 @@ const Profile = (props: any) => {


if (!profile) {
return (<Spinner size={SpinnerSize.medium} />);
return (<Spinner size={SpinnerSize.medium} styles={profileSpinnerStyles} />);
}

const handleSignOut = () => {
Expand Down
16 changes: 11 additions & 5 deletions src/app/views/main-header/MainHeader.styles.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { ITheme } from '@fluentui/react';

export const mainHeaderStyles = (theme: ITheme, props?: any) => {
export const mainHeaderStyles = (theme: ITheme) => {
return {
rootStyles: {
root: {
background: theme.palette.neutralLighter,
height: 50,
marginBottom: props && props.token ? '0px' : '-9px'
marginBottom: '9px'
}
},
authenticationItemStyles: {
alignItems: 'center',
display: 'flex'
rightItemsStyles: {
root: {
alignItems: 'center'
}
},
feedbackIconAdjustmentStyles: {
position: 'relative' as 'relative',
right: '-6px',
top: '4px'
}
}
}
27 changes: 12 additions & 15 deletions src/app/views/main-header/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ const itemAlignmentsStackTokens: IStackTokens = {
};

export const MainHeader: React.FunctionComponent <MainHeaderProps> = (props: MainHeaderProps) => {
const { authToken, profile } = useSelector(
const { profile } = useSelector(
(state: IRootState) => state
);
const minimised = props.minimised;
const currentTheme = getTheme();
const itemAlignmentStackStyles = mainHeaderStyles(currentTheme, authToken).rootStyles;
const itemStyles = mainHeaderStyles(currentTheme).authenticationItemStyles;
const itemAlignmentStackStyles = mainHeaderStyles(currentTheme).rootStyles;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These can all be destructured into a one liner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. Done

const rightItemsStyles = mainHeaderStyles(currentTheme).rightItemsStyles;
const feedbackIconAdjustmentStyles = mainHeaderStyles(currentTheme).feedbackIconAdjustmentStyles;

return (
<Stack tokens={sectionStackTokens}>
Expand Down Expand Up @@ -71,9 +72,8 @@ export const MainHeader: React.FunctionComponent <MainHeaderProps> = (props: Mai
</Label>
</Stack>

<Stack >
<span style={itemStyles}>
{!profile &&
<Stack horizontal styles={rightItemsStyles}>
{!profile &&
<TooltipHost
content={
<>
Expand All @@ -85,19 +85,16 @@ export const MainHeader: React.FunctionComponent <MainHeaderProps> = (props: Mai
>
<DefaultButton text={translateMessage('Sample Tenant')} checked={true} style={{border: 'none'}}/>
</TooltipHost>
}
{profile &&
}
{profile &&
<DefaultButton text={`${profile.tenant} Tenant`} checked={true} style={{border: 'none', cursor: 'default'}}
/>
}
<FeedbackButton />
<Settings />
<Authentication />
</span>
<span style={itemStyles}></span>
}
<span style={feedbackIconAdjustmentStyles}> <FeedbackButton /> </span>
<Settings />
<Authentication />
</Stack>
</Stack>
</Stack>
);
};