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

Buttons separators in RWD mobile should not be full height #8232

Merged
merged 16 commits into from
Oct 20, 2020
Merged

Conversation

pkwasnik
Copy link
Contributor

@pkwasnik pkwasnik commented Oct 9, 2020

Suggested merge commit message (convention)

Fix (link): Implementing not full height separators. Closes #7704.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@pkwasnik pkwasnik requested a review from jodator October 9, 2020 06:58
@jodator jodator self-assigned this Oct 9, 2020
Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

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

I'm not sure about the approach, so I would double-check this with @oleq .

Apart from that 👍 for picking up tests in the right way for the added element.

@@ -24,6 +24,7 @@ import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
import checkIcon from '@ckeditor/ckeditor5-core/theme/icons/check.svg';
import cancelIcon from '@ckeditor/ckeditor5-core/theme/icons/cancel.svg';
import '../../theme/linkform.css';
import ToolbarSeparatorView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarseparatorview';
Copy link
Contributor

Choose a reason for hiding this comment

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

This import should go alongside other code imports, preferably glued together with similar imports (ie after LabeledFieldVIew import).

We like tidy imports :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, corrected

@@ -85,6 +86,8 @@ export default class LinkFormView extends View {
*/
this.cancelButtonView = this._createButton( t( 'Cancel' ), cancelIcon, 'ck-button-cancel', 'cancel' );

this.separatorView = new ToolbarSeparatorView();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this is not a good way to go. The ToolbarSeparatorView is used (AFAIR for now) only inside the toolbar.

Maybe here we could just adjust buttons' CSS to achieve the required UI.

// cc @oleq

@@ -331,6 +334,7 @@ export default class LinkFormView extends View {
}

children.add( this.saveButtonView );
children.add( this.separatorView );
Copy link
Contributor

Choose a reason for hiding this comment

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

I've fortgot to check that also the main view for the links needs update:

children: [
this.previewButtonView,
this.editButtonView,
this.unlinkButtonView
]

Sorry for that - I've figured out this after looking how this behaves. So we heve here:

  1. LinkActionsView

  1. LinkFormView

Selection_072

Comment on lines 36 to 37
margin-top: calc(var(--ck-spacing-large) + var(--ck-spacing-extra-tiny));
margin-bottom: var(--ck-spacing-small);
Copy link
Contributor

Choose a reason for hiding this comment

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

Something looks odd when I've tested it locally. See the screenshot for LinkFormView.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I've found that it looks OK if no manual decorators are defined:

@oleq oleq self-requested a review October 12, 2020 07:55
Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

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

Aside from the fact that the solution breaks in certain situations

I think this direction is a dead-end. Some more thoughts:

  1. The action buttons are not a toolbar so using ToolbarSeparatorView in this context is a no-go.
  2. We cannot convert these buttons into a toolbar because... they are not a toolbar. Toolbars carry specific semantics and this is not the case.
  3. I'd see what we can do using ::before or ::after pseudo-selectors for the buttons (pure CSS approach). For instance .ck-button::after:
border-right: 1px solid var(--ck-color-base-border);
content: "";
width: 0;
position: absolute;
right: -1px;
top: var(--ck-spacing-small);
bottom: var(--ck-spacing-small);
z-index: 1;

results in something like this (ignore the broken toggle switches, it's just a PoC and I didn't narrow the selector)

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

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

The mobile views are now OK 👍

However, the separator is now lost in manual decorators samples

PR master
Selection_074 Selection_075

@oleq - Previously we had this style copied 3 times (I see 3 deletions in this PR). For a single line style, it doesn't look like a big overhead. Adding more properties means that we have to copy them in 3 places. Do we have any strategy or pattern for duplicated definitions?

@oleq
Copy link
Member

oleq commented Oct 14, 2020

Adding more properties means that we have to copy them in 3 places. Do we have any strategy or pattern for duplicated definitions?

Yeah. Normally we create a class and then it's shared across the use-cases. The story here is tricky, though because there's also the text alternative form that needs to be addressed and that means the styles must be shared across packages and cannot live in ckeditor5-link or ckeditor5-image. 

Some cake recipe (not sure it tastes good, though):

  • Let's have .ck-responsive-form together with .ck-text-alternative-form, .ck-link-form, and .ck-link-actions (in TextAlternativeFormView, LinkFormView, LinkActionsView),
  • Let's have ckeditor5-ui/theme/components/responsive-form/responsiveform.css (for wireframe part), 
  • Let's have ckeditor5-theme-lark/theme/ckeditor5-ui/components/responsive-form/responsiveform.css  (for theme part). ATM both wireframe and theme CSS are in the same file. I really need to address Document and explain CSS organization in the project #7702 to make it clear, sorry for that 😞
  • Let's make the &::after { ... } solution work as .ck-responsive-form some-sane-selector-that-reaches-the-correct-button::after { ... } both in responsive mode and when .ck-link-form_layout-vertical is used. This is tricky and needs to be thought through.
    • It could be we need something like this:
/* Either of responsiveform.css */

/* This one can be used here https://github.com/ckeditor/ckeditor5/blob/0706215c592edcf1b701b4af63298f4b77f8dd01/packages/ckeditor5-link/src/ui/linkformview.js#L139 */
/* It simply enforces the mode when the class is set. */
.ck-vertical-form some-sane-selector-that-reaches-the-correct-button::after {
	/* Some CSS. */
}

/* This one is smart and works based on media queries. */
@mixin ck-media-phone {
	.ck-responsive-form some-sane-selector-that-reaches-the-correct-button::after {
		/* Same CSS as above. */
	}
}

@jodator
Copy link
Contributor

jodator commented Oct 14, 2020

I really need to address #7702 to make it clear, sorry for that

It would be lovely if you could manage to find time for that 😍  having those written down would also mean fewer pings from others 😉

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Only one request to @pkwasnik about documenting the button.ck-button usage and we can merge it.

}
}

& button.ck-button {
Copy link
Contributor

Choose a reason for hiding this comment

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

@pkwasnik Could you add a comment on why there's button.ck-button is needed. It wasn't obvious to me why this is needed.

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jodator jodator merged commit 6aecaf8 into master Oct 20, 2020
@jodator jodator deleted the i/7704 branch October 20, 2020 09:11
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.

Buttons separators in RWD mobile should not be full height
3 participants