Skip to content

Commit

Permalink
fix layout of parameter editor
Browse files Browse the repository at this point in the history
adjust layout and fix tooltip positioning
  • Loading branch information
PRGfx committed Oct 2, 2023
1 parent 66b4bbb commit 7e0d23c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const containerStyles = (collapsed: boolean): React.CSSProperties => ({
flexWrap: 'wrap',
gap: 8,
});
const groupStyles: React.CSSProperties = {
flexGrow: 1,
};

const isCollapsed = (props: LinkAttributeGroupProps): boolean =>
props.collapsed === true && props.options.every(({ attribute }) => {
Expand Down Expand Up @@ -79,7 +82,7 @@ export const LinkAttributeGroup: React.FunctionComponent<LinkAttributeGroupProps
{props.options.map((option, i) => {
const inputId = `link-attribute-input-${i}`;
return (
<div key={option.attribute}>
<div key={option.attribute} style={groupStyles}>
<LinkAttributeLabel
option={option}
inputId={inputId}
Expand Down
32 changes: 26 additions & 6 deletions Resources/Private/LinkEditor/src/components/LinkAttributeLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,44 @@ type LinkAttributeLabelProps = {
inputId: string;
i18nRegistry: {translate: (key: string) => string};
}

const styles = {
wrapper: {
position: 'relative',
},
container: {
display: 'flex',
justifyContent: 'space-between',
},
tooltipWrapper: {
position: 'relative',
zIndex: 10,
},
infoButton: {
cursor: 'pointer',
},
} satisfies Record<string, React.CSSProperties>;

export const LinkAttributeLabel: React.FunctionComponent<LinkAttributeLabelProps> = ({ inputId, option, i18nRegistry }) => {
const [ helpOpen, setHelpOpen ] = useState(false);
const toggleHelpMessage = () => setHelpOpen(current => !current);

return (
<div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div style={styles.wrapper}>
<div style={styles.container}>
<Label htmlFor={inputId}>{i18nRegistry.translate(option.label)}</Label>
{option.help && (
<span role="button" onClick={toggleHelpMessage}>
<span role="button" onClick={toggleHelpMessage} style={styles.infoButton}>
<Icon icon="question-circle"/>
</span>
)}
</div>
{option.help && helpOpen && (
<Tooltip renderInline>
{i18nRegistry.translate(option.help)}
</Tooltip>
<div style={styles.tooltipWrapper}>
<Tooltip>
{i18nRegistry.translate(option.help)}
</Tooltip>
</div>
)}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/Plugin/LinkEditor/Plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e0d23c

Please sign in to comment.