-
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
Draft
okaeiz
wants to merge
5
commits into
bpmn-io:develop
Choose a base branch
from
okaeiz:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9120642
chore: update dependency @rollup/plugin-commonjs to v26
renovate[bot] 6520e02
Implemented RTL adherence for Action and Selection components
okaeiz 79d38e9
Added DirectionEntry to the AppearanceGroup
okaeiz 53980fa
Implemented RTL adherence for Input and Presentation and Containers c…
okaeiz 569c889
fixed some of the reviewer issues
okaeiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/form-js-editor/src/features/properties-panel/entries/DirectionEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { get } from 'min-dash'; | ||
import { useService, useDirection } from '../hooks'; | ||
import { SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function DirectionEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = [ | ||
{ | ||
id: 'direction', | ||
component: Direction, | ||
editField, | ||
field, | ||
isEdited: isSelectEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'default', | ||
}, | ||
]; | ||
|
||
return entries; | ||
} | ||
|
||
function Direction(props) { | ||
const { editField, field } = props; | ||
const { setDirection } = useDirection(); | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const path = ['direction']; | ||
|
||
const getValue = () => { | ||
const value = get(field, path, 'ltr'); | ||
return value; | ||
}; | ||
|
||
const setValue = (value) => { | ||
setDirection(value); | ||
return editField(field, path, value || 'ltr'); | ||
}; | ||
|
||
const getOptions = () => [ | ||
{ | ||
label: 'Left to Right', | ||
value: 'ltr', | ||
}, | ||
{ | ||
label: 'Right to Left', | ||
value: 'rtl', | ||
}, | ||
]; | ||
|
||
return SelectEntry({ | ||
debounce, | ||
element: field, | ||
getValue, | ||
id: 'direction', | ||
label: 'Direction', | ||
setValue, | ||
getOptions, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/form-js-editor/src/features/properties-panel/groups/AppearanceGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/form-js-editor/src/features/properties-panel/hooks/DirectionContext.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useContext } from 'preact/hooks'; | ||
import { createContext } from 'preact'; | ||
|
||
const DirectionContext = createContext({ | ||
direction: 'ltr', | ||
setDirection: (direction) => {}, | ||
}); | ||
|
||
export function useDirection() { | ||
const context = useContext(DirectionContext); | ||
if (!context) { | ||
throw new Error('useDirection must be used within a DirectionProvider'); | ||
} | ||
return context; | ||
} | ||
|
||
// // hooks/useDirection.js | ||
// import { useContext } from 'preact/hooks'; | ||
// import { FormContext } from '../context/FormContext'; // Adjust the path as necessary | ||
|
||
// export function useDirection() { | ||
// const form = useContext(FormContext); | ||
// const { schema } = form._getState(); | ||
// const direction = schema?.direction || 'ltr'; | ||
// return direction; | ||
// } |
1 change: 1 addition & 0 deletions
1
packages/form-js-editor/src/features/properties-panel/hooks/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { useVariables } from './useVariables'; | ||
export { useService } from './usePropertiesPanelService'; | ||
export { useDirection } from './DirectionContext'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
✅