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

Clean up spacing in login modal in Connect #48143

Merged
merged 8 commits into from
Nov 4, 2024
Merged

Conversation

ravicious
Copy link
Member

@ravicious ravicious commented Oct 30, 2024

Closes #48059.

The spacing in ClusterConnect was a little bit all over the place with individual elements setting their own paddings and margins. I tried to limit it as much as possible, only to discover that it's not as simple as setting a uniform padding in dialogCss in ClusterConnect.

That's because the login modal utilizes StepSlider which has individual children that slide from one side to another. In order for the animation to look seamless, those individual children need to occupy the whole width of the parent component. Otherwise they'll slide within the boundaries set by the padding of the parent, as seen in the video below.

An example of how padding affects animation

In the first implementation, the whole form slides from side to side. In the other implementation, it hides behind the parent padding when going offscreen.

modal-spacing.mov

Unfortunately, a lot of our design elements set margins by themselves which is not useful when you want to set gaps uniformly with gap. This means that despite switching a lot of places to use <Flex gap={…}>, I still had to specify things like m={0} in a lot of places.

In addition, I tried to curb the spacing a little bit, this is most clearly shown when comparing ClusterAdd to the previous implementation. The idea is that if the outermost padding is set to 4, components within the dialog should not use this spacing value (or bigger) to space out elements, especially when it comes to vertical spacing. Otherwise it can lead to situations where an element is closer to a modal border than it is to another element in the modal, making those two elements appear disjointed and out of place. Spacing should be used to group elements meant to appear together.

Demo

In the first tab there's a version from master, in the second tab there's the version from this branch.

cluster-connect-spacing-2.mov

@ravicious ravicious added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Oct 30, 2024
* in ClusterLogin are able to span the whole width of the parent component. This way when they
* slide, they slide from one slide to another, without disappearing behind padding.
*/
export const dialogCss: StyleFunction<NoExtraProps> = props =>
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this to a separate file because otherwise it breaks fast refresh in @vitejs/plugin-react-swc. Not sure how worthwhile this is, as within stories fast refresh is broken anyway as each story has a default export which is not a React component.

https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports

@ravicious ravicious marked this pull request as ready for review October 30, 2024 17:05
@ravicious ravicious requested a review from gzdunek October 30, 2024 17:05
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-48143.d3pp5qlev8mo18.amplifyapp.com

@github-actions github-actions bot requested review from avatus and kiosion October 30, 2024 17:06
@ravicious ravicious requested review from kimlisa and removed request for avatus and kiosion October 30, 2024 17:07
Copy link
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up!

Comment on lines 39 to 56
loginAttempt: {
status: '',
statusText: '',
} as Attempt<void>,
init: () => null,
initAttempt: {
status: 'success',
statusText: '',
data: {
localAuthEnabled: true,
authProviders: [],
type: '',
hasMessageOfTheDay: false,
allowPasswordless: true,
localConnectorName: '',
authType: 'local',
} as types.AuthSettings,
} as const,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can avoid these assertions, which actually hide some types issues.

Suggested change
loginAttempt: {
status: '',
statusText: '',
} as Attempt<void>,
init: () => null,
initAttempt: {
status: 'success',
statusText: '',
data: {
localAuthEnabled: true,
authProviders: [],
type: '',
hasMessageOfTheDay: false,
allowPasswordless: true,
localConnectorName: '',
authType: 'local',
} as types.AuthSettings,
} as const,
loginAttempt: {
status: '',
statusText: '',
data: null,
},
init: () => null,
initAttempt: {
status: 'success',
statusText: '',
data: {
localAuthEnabled: true,
authProviders: [],
hasMessageOfTheDay: false,
allowPasswordless: true,
localConnectorName: '',
authType: 'local',
},
},

@@ -73,7 +81,7 @@ export default function LoginForm(props: Props) {

if (!localAuthEnabled) {
return (
<FlexBordered p={4}>
<FlexBordered px={outermostPadding}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add m={0} to remove the space at the bottom:
image

@ravicious ravicious enabled auto-merge November 4, 2024 12:18
@ravicious ravicious added this pull request to the merge queue Nov 4, 2024
Merged via the queue into master with commit eb0a427 Nov 4, 2024
40 checks passed
@ravicious ravicious deleted the r7s/cluster-login-spacing branch November 4, 2024 12:34
@public-teleport-github-review-bot

@ravicious See the table below for backport results.

Branch Result
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/sm ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misaligned alert when error happens during SSO login in Connect
3 participants