-
Notifications
You must be signed in to change notification settings - Fork 0
style(preview_onFocus): try_add_borders_in_field_preview_when_edit_field_is_onFocus #20
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
813b6d9
5de407e
fd6098c
696236e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { | |
| DRAFT_CREATE_EMPTY, | ||
| DRAFT_DISCARD, | ||
| DRAFT_CHANGE_FIELD, | ||
| DRAFT_FOCUS_FIELD, | ||
| DRAFT_VALIDATION_ERRORS, | ||
| DRAFT_CLEAR_ERRORS, | ||
| DRAFT_LOCAL_BACKUP_RETRIEVED, | ||
|
|
@@ -117,7 +118,29 @@ function entryDraftReducer(state = Map(), action) { | |
| state.set( | ||
| 'hasChanged', | ||
| !entries.some(e => newData.equals(e.get(...dataPath))) || | ||
| !entries.some(e => newMeta.equals(e.get('meta'))), | ||
| !entries.some(e => newMeta.equals(e.get('meta'))), | ||
| ); | ||
| }); | ||
| } | ||
| case DRAFT_FOCUS_FIELD: { | ||
| return state.withMutations(state => { | ||
|
|
||
| const { field, value, metadata, entries, i18n } = action.payload; | ||
| const name = field.get('name'); | ||
| window.previewStyle = { | ||
| name: field.get('name'), | ||
| label: field.get('label'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Humm esse label é para identificar o componente que foi triggado. Posso montar o objeto de outra forma.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Não não, na verdade seria pra eu conseguir identificar o field que foi alterado em nested objects... "sections": [
{
"type": "banner",
"image": {
"src": ""
}
}
]Se ele editar a imagem do banner, eu só conseguiria identificar qual elemento foi alterado se o |
||
| } | ||
| const dataPath = (i18n && getDataPath(i18n.currentLocale, i18n.defaultLocale)) || ['data']; | ||
| state.setIn(['entry', 'meta', name], value); | ||
|
|
||
| state.mergeDeepIn(['fieldsMetaData'], fromJS(metadata)); | ||
| const newData = state.getIn(['entry', ...dataPath]); | ||
| const newMeta = state.getIn(['entry', 'meta']); | ||
| state.set( | ||
| 'hasFocused', | ||
| !entries.some(e => newData.equals(e.get(...dataPath))) || | ||
| !entries.some(e => newMeta.equals(e.get('meta'))), | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,12 @@ function toValue(value, field) { | |
|
|
||
| function CodePreview(props) { | ||
| return ( | ||
| <WidgetPreviewContainer> | ||
| <WidgetPreviewContainer | ||
| style={{ | ||
| borderStyle: | ||
| props?.field.get('name') === window?.previewStyle?.name && props?.field.get('label') === window?.previewStyle?.label | ||
| ? 'dotted' : 'none' | ||
| }}> | ||
|
Comment on lines
+20
to
+24
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. na verdade nem era necessário mexer nos previews padrão de cada widget, isso é só pro custom preview, nesse caso nenhum
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Peguei pelos WidgetPreviewContainer pq eles envolvem o componente, então a borda fica certa em volta do componente
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Então, mas o Isso é um print do nosso custom preview, se estivéssemos usando os previews padrão de cada componente não apareceria dessa forma... No nosso caso não temos um preview para cada widget (até porque como tem o list widgets variable types pras sections, não adiantaria ter um preview por widget), temos um único componente pro preview que renderiza a página inteira, sacou? |
||
| <pre> | ||
| <code>{toValue(props.value, props.field)}</code> | ||
| </pre> | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.