Skip to content

Commit

Permalink
Add a warning when targeting an acestor with a reference
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Apr 20, 2024
1 parent 8d71b27 commit 686599c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/components/Grid/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export function Grid ({ children, data = {}, onChange }) {
userIsEditingLayout &&
<Notification
icon='edit'
type='inline'
title='Editing layout'
description='Right click to manage widgets'
controls={<button className='Button Button--ghost' onClick={() => handleLeaveEditMode()}>Leave edit mode</button>}
Expand Down
2 changes: 1 addition & 1 deletion app/components/Notification/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function Notification ({ type, size = 'normal', icon, title, description,
<div className={`Notification Notification--${type} Notification-size--${size}`}>
<div className='Notification-content'>
{
icon && <span className='Notification-contentSection'><Icon name={icon} /></span>
icon && <span className='Notification-contentSection Notification-icon'><Icon name={icon} color='var(--color-text)' /></span>
}
{
title && <span className='Notification-contentSection Notification-title'>{title}</span>
Expand Down
27 changes: 24 additions & 3 deletions app/components/Notification/style.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
.Notification {
display: flex;

width: 100%;

box-sizing: border-box;
justify-content: space-between;

color: var(--base-color--notificationColor);
background-color: var(--base-color--notificationBackground);

border-radius: 6px;

--color-warning: #FFDC8C;
--color-text: var(--base-color--notificationColor);

color: var(--color-text);
}

.Notification--inline {
border-radius: 0;
}

.Notification-size--normal {
Expand All @@ -22,6 +31,8 @@
.Notification-content {
display: flex;
align-items: center;

color: var(--color-text);
}

.Notification-size--normal .Notification-content {
Expand Down Expand Up @@ -51,5 +62,15 @@

.Notification--warning *,
.Notification--warning .Notification-hideBtn {
color: black;
}
--color-text: black;
}

.Notification-hideBtn {
color: var(--color-text);
}

.Notification-icon,
.Notification-icon .Icon {
width: 1.5em;
height: 1.5em;
}
6 changes: 5 additions & 1 deletion app/components/Sharing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export function Sharing ({ open, onClose = () => {} }) {
<div className='Sharing u-theme--light'>
{
HOST === 'localhost' &&
<Notification size='small' description='Bridge is only accessible on localhost, change this in settings' />
(
<div className='Sharing-notification'>
<Notification size='small' description='Bridge is only accessible on localhost, change this in settings' />
</div>
)
}
<div className='Sharing-content'>
<div className='Sharing-icon' dangerouslySetInnerHTML={{ __html: CollaborationIcon }} />
Expand Down
4 changes: 4 additions & 0 deletions app/components/Sharing/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@

.Sharing-icon {
margin: 5px 0 10px;
}

.Sharing-notification {
padding: 5px;
}
11 changes: 11 additions & 0 deletions plugins/inspector/app/components/Form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ import './style.css'
import { StoreContext } from '../../storeContext'

import { Accordion } from '../Accordion'

import { Frame } from '../../../../../app/components/Frame'
import { Notification } from '../../../../../app/components/Notification'

import { TextInput } from '../TextInput'
import { ColorInput } from '../ColorInput'
import { StringInput } from '../StringInput'
import { SelectInput } from '../SelectInput'
import { BooleanInput } from '../BooleanInput'


const INPUT_COMPONENTS = {
boolean: BooleanInput,
string: StringInput,
Expand Down Expand Up @@ -244,6 +247,14 @@ export function Form () {
return (
<div className='Form'>
<div className='Form-section'>
<div className='Form-notifications'>
{
Object.values(store.items?.[0]?.issues ?? {})
.map((issue, i) => {
return <Notification key={i} description={issue?.description} type='warning' icon='warning' size='small' />
})
}
</div>
<div className='Form-row'>
<ColorInput value={getValue('color')} onChange={value => handleDataChange('color', value)} />
<StringInput value={getValue('name')} onChange={value => handleDataChange('name', value)} large />
Expand Down
5 changes: 5 additions & 0 deletions plugins/inspector/app/components/Form/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@
font-size: 0.9em;

box-sizing: border-box;
}

.Form-notifications .Notification {
margin-top: -10px;
margin-bottom: 15px;
}
2 changes: 1 addition & 1 deletion plugins/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const ITEM_CHANGE_HANDLERS = {
}

bridge.items.applyIssue(item?.id, 'types.rta', {
description: 'Be careful referencing ancestor as loops may occur'
description: 'Reference is targeting an ancestor, loops may occur'
})
}
}
Expand Down

0 comments on commit 686599c

Please sign in to comment.