Skip to content
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

feat(header): add documentation ref #141

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/properties-panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@
margin-top: -6px;
}

.bio-properties-panel-header-actions {
margin-left: auto;
margin-top: auto;
}

/**
* Scroll container
*/
Expand Down
24 changes: 21 additions & 3 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { ExternalLinkIcon } from './icons';

/**
* @typedef { { getElementLabel: Function, getTypeLabel: Function, getElementIcon: Function } } HeaderProvider
* @typedef { {
* getElementLabel: (element: djs.model.base) => string,
* getTypeLabel: (element: djs.model.base) => string,
* getElementIcon: (element: djs.model.base) => import('preact').Component,
* getDocumentationRef: (element: djs.model.base) => string
* } } HeaderProvider
*/

/**
Expand All @@ -15,13 +22,16 @@ export default function Header(props) {
} = props;

const {
getElementIcon,
getDocumentationRef,
getElementLabel,
getTypeLabel,
getElementIcon
} = headerProvider;

const label = getElementLabel(element);
const type = getTypeLabel(element);
const documentationRef = getDocumentationRef && getDocumentationRef(element);

const ElementIcon = getElementIcon(element);

return (<div class="bio-properties-panel-header">
Expand All @@ -30,10 +40,18 @@ export default function Header(props) {
</div>
<div class="bio-properties-panel-header-labels">
<div title={ type } class="bio-properties-panel-header-type">{ type }</div>
{ getElementLabel(element) ?
{ label ?
<div title={ label } class="bio-properties-panel-header-label">{ label }</div> :
null
}
</div>
<div class="bio-properties-panel-header-actions">
{ documentationRef ?
<a rel="noopener" class="bio-properties-panel-header-link" href={ documentationRef } target="_blank">
<ExternalLinkIcon />
</a> :
null
}
</div>
</div>);
}
1 change: 1 addition & 0 deletions src/components/icons/ExternalLink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/icons/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as ArrowIcon } from './Arrow.svg';
export { default as CreateIcon } from './Create.svg';
export { default as DeleteIcon } from './Delete.svg';
export { default as ExternalLinkIcon } from './ExternalLink.svg';
export { default as FeelRequiredIcon } from './FeelRequired.svg';
export { default as FeelOptionalIcon } from './FeelOptional.svg';
38 changes: 38 additions & 0 deletions test/spec/components/Header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,44 @@ describe('<Header>', function() {
expect(iconNode).to.exist;
});

it('should NOT render documentation ref', function() {

// given
const provider = {
getElementLabel: () => 'name',
getTypeLabel: () => 'type',
getElementIcon: () => 'icon'
};

// when
const result = render(<Header headerProvider={ provider } />, { container });

const documentationNode = domQuery('.bio-properties-panel-header-link', result.container);

// then
expect(documentationNode).to.not.exist;
});


it('should render documentation ref', function() {

// given
const provider = {
getElementLabel: () => 'name',
getTypeLabel: () => 'type',
getElementIcon: () => 'icon',
getDocumentationRef: () => 'https://example.com'
};

// when
const result = render(<Header headerProvider={ provider } />, { container });

const documentationNode = domQuery('.bio-properties-panel-header-link', result.container);

// then
expect(documentationNode).to.exist;
});


describe('a11y', function() {

Expand Down