-
Notifications
You must be signed in to change notification settings - Fork 107
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
RTL direction support via properties panel (revised) #1213
base: develop
Are you sure you want to change the base?
Conversation
8f337a7
to
6520e02
Compare
Here's the demo for Action and Selection components: RTL-Demo-Selection.Action.mp4 |
Here's the demo for Input, Presentation and Containers components: RTL-Demo-InputContainersPresentation.mp4 |
This looks completed to me. Here's a recap:
I did NOT change the HTML View because its direction can already be changed via CSS attributes. @Skaiir I'd appreciate it if you take a look at this. |
Currently working on a review of this @okaeiz. Amazing work already, although there will need to be a few things changed before we can approve :D. But I'm confident together we'll get this into the library rather soon ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've mentioned a few things, but overall the direction is very good. There are a few things missing, although we don't need to tackle everything (but would be nice):
- Unimplemented
- HTML should also be covered as a default (if it is relatively simple), yes you can define it within the code, but having a single configuration handle everything is just generally good.
- The field placeholders (1*) should probably be RTL as well, just for visual consistency. But this isn't super important.
- Iframe title should also be aligned (iframe content shouldn't be modified though, that is correct)
- Issues
- Delete icon overlapping label (2*), would flip the button alignment
- Separator for the number field on the wrong side (2*) (should be flipped)
- Spacing between button and text in dynamic lists are squashed (4*), they might need some cleaning up
For these smaller things, what will be needed is to make adjustments to the styles. So what I would do is, based on the direction setting, set a new class to the root of the form renderer. Then we'd modify the CSS using this tag to adjust those small things.
As mentioned, regarding the fonts, we can discuss this at the end.
Also, ensure that you pass our CI via the npm run all command. It'll show you any issues with the code.
It's a lot of text on my part, but it shouldn't be a ton of changes. You don't need to close the PR, just force push your fixes to the PR.
Nice work so far, this will be a very useful change.
import { get } from 'min-dash'; | ||
import { useService } from '../hooks'; | ||
import { SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel'; | ||
import { useDirection } from '../../../../../form-js-viewer/src/render/context/DirectionContext'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is that you're directly referencing the file across packages. See DateTimeConstraintsEntry
for an example of how you can reference the viewer library (you have to ensure it is exported from the viewer).
What I would do is, in the properties-panel hooks file, add an export referencing the viewer package, and then in this file reference the hook with useService
import { useService, useDirection } from '../hooks';
Just to keep things clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
packages/form-js-editor/src/features/properties-panel/entries/DirectionEntry.js
Outdated
Show resolved
Hide resolved
packages/form-js-editor/src/features/properties-panel/entries/DirectionEntry.js
Outdated
Show resolved
Hide resolved
@@ -39,3 +39,5 @@ export { RowCountEntry } from './RowCountEntry'; | |||
export { HeadersSourceSelectEntry } from './HeadersSourceSelectEntry'; | |||
export { ColumnsExpressionEntry } from './ColumnsExpressionEntry'; | |||
export { StaticColumnsSourceEntry } from './StaticColumnsSourceEntry'; | |||
export { DirectionEntry } from './DirectionEntry'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're using vscode
, install the prettier code formatter app, and also eslint, it will show you errors you're missing and adhere to our formatting rules.
If you're using another software to code I'm not sure if they have support for it but either way both have CLIs, so you can use the CLI to fix things up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
packages/form-js-editor/src/features/properties-panel/groups/AppearanceGroup.js
Outdated
Show resolved
Hide resolved
const form = useService('form'); | ||
const { schema } = form._getState(); | ||
|
||
const direction = schema?.direction || 'ltr'; // Fetch the direction value from the form schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, you should try and go for a single useDirection
hook like you had in the properties panel. The reason for this is that, firstly it's more readable, but also if we decide to change how it behaves, we only need to change it in on spot. It's also less error prone.
class={formFieldClasses(type)} | ||
style={{ | ||
direction: direction, | ||
fontFamily: 'Vazirmatn, sans-serif', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a css variable that defines fontFamily, so you can set it across the entire application rather easily (in general you'll find we don't use inline styles much, except for alignment). So if we're implementing it within the form-js, we should do it in one place only (somewhere in the form root).
For now, because I still need to understand a little bit more about the font stuff, please just remove it. We'll get back to it when everything else is done.
PS: the comments on this file apply across the board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the font; but I kindly ask you to reconsider this decision. The font makes no difference to English and the languages that have a similar alphabet to English. But in Persian, it is one of the main (if not the main) reasons why people decide not to use a software.
If you take a look at Github, you'll find out that Github is also using Vazirmatn for its Persian strings. It is highly admired among open-source community.
I made a new commit. Here's a recap:
I did NOT change the Expression field because whenever we have an LTR field in the RTL direction (such as expressions, emails, URLs, etc.) the placeholder should also be LTR; otherwise it will be confusing for the users. @Skaiir I'd appreciate it if you take a look at this. |
Any updates? |
Hey @okaeiz, sorry we haven't been able to be around, unfortunately things got pretty busy pretty fast. I do have some amount of time now so I'll catch up with this today. |
Apologies for the delays it looks like this won't get taken a look at for another week at least. Unfortunately some other priorities came up. |
Take your time. I'll be available for further modifications. |
What is the status of this PR? Should I give up already? |
Has worked on #1205
This PR (within the the first commit) adds a new form-js entry named
DirectionEntry
to the properties panelAppearanceGroup
that is activated for the form component (default type).It is also intended to modify form components to adhere to the direction setting that is selected from the
DirectionEntry
.