-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2182 from tf/info-table
Add info table content element
- Loading branch information
Showing
27 changed files
with
2,136 additions
and
12 deletions.
There are no files selected for viewing
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,50 @@ | ||
de: | ||
pageflow: | ||
info_table_content_element: | ||
feature_name: Info-Tabelle Element | ||
pageflow_scrolled: | ||
editor: | ||
content_elements: | ||
infoTable: | ||
description: Zweispaltige Tabelle mit Name/Wert-Paaren. | ||
name: Info-Tabelle | ||
tabs: | ||
general: Info-Tabelle | ||
help_texts: | ||
shortcuts: |- | ||
<dl class="shortcuts"> | ||
<dt> | ||
<span class="shortcut"> | ||
<kbd>Enter</kbd> | ||
</span> | ||
<span class="inline_help"> | ||
Füge eine neue Tabellenzeile hinzu. | ||
</span> | ||
</dt> | ||
<dd> | ||
Tabellenzeile einfügen | ||
</dd> | ||
<dt> | ||
<span class="shortcut"> | ||
<kbd>Shift</kbd> + <kbd>Enter</kbd> | ||
</span> | ||
<span class="inline_help"> | ||
Füge eine neue Zeile innerhalb einer Tabellenzelle ein. | ||
</span> | ||
</dt> | ||
<dd> | ||
Zeilenumbruch einfügen | ||
</dd> | ||
<dt> | ||
<span class="shortcut"> | ||
<kbd>Alt</kbd> + <kbd>Enter</kbd> | ||
</span> | ||
<span class="inline_help"> | ||
Füge potentielle Zeilenumbruchspunkte in lange Worte ein, | ||
um Silbentrennung zu ermöglichen. | ||
</span> | ||
</dt> | ||
<dd> | ||
Bedingten Trennstrich einfügen | ||
</dd> | ||
</dl> |
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,50 @@ | ||
en: | ||
pageflow: | ||
info_table_content_element: | ||
feature_name: Info table element | ||
pageflow_scrolled: | ||
editor: | ||
content_elements: | ||
infoTable: | ||
description: Two-column table for label value pairs. | ||
name: Info Table | ||
tabs: | ||
general: Info Table | ||
help_texts: | ||
shortcuts: |- | ||
<dl class="shortcuts"> | ||
<dt> | ||
<span class="shortcut"> | ||
<kbd>Enter</kbd> | ||
</span> | ||
<span class="inline_help"> | ||
Add a new row to the table.. | ||
</span> | ||
</dt> | ||
<dd> | ||
Insert table row | ||
</dd> | ||
<dt> | ||
<span class="shortcut"> | ||
<kbd>Shift</kbd> + <kbd>Enter</kbd> | ||
</span> | ||
<span class="inline_help"> | ||
Insert a new line without beginning a new paragraph. | ||
</span> | ||
</dt> | ||
<dd> | ||
Insert soft break/new line | ||
</dd> | ||
<dt> | ||
<span class="shortcut"> | ||
<kbd>Alt</kbd> + <kbd>Enter</kbd> | ||
</span> | ||
<span class="inline_help"> | ||
Specify potential line break points within long words | ||
to control hyphenation. | ||
</span> | ||
</dt> | ||
<dd> | ||
Insert soft hyphen | ||
</dd> | ||
</dl> |
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
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
149 changes: 149 additions & 0 deletions
149
entry_types/scrolled/package/spec/frontend/EditableTable-spec.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,149 @@ | ||
import React from 'react'; | ||
|
||
import {EditableTable} from 'frontend'; | ||
|
||
import {render, screen} from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect' | ||
|
||
describe('EditableTable', () => { | ||
it('renders class name on table', () => { | ||
render(<EditableTable value={[]} | ||
className="some-class" />); | ||
|
||
expect(screen.getByRole('table')).toHaveClass('some-class'); | ||
}); | ||
|
||
it('renders table with label and value typography classes on cells', () => { | ||
const value = [ | ||
{ | ||
type: 'row', | ||
children: [ | ||
{ | ||
type: 'label', | ||
children: [ | ||
{text: 'Name'} | ||
] | ||
}, | ||
{ | ||
type: 'value', | ||
children: [ | ||
{text: 'Jane'} | ||
] | ||
} | ||
] | ||
} | ||
]; | ||
|
||
render(<EditableTable value={value} | ||
labelScaleCategory="infoTableLabel" | ||
valueScaleCategory="infoTableValue" />); | ||
|
||
expect( | ||
screen.getByRole('cell', {name: 'Name'}).querySelector('.typography-infoTableLabel') | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole('cell', {name: 'Jane'}).querySelector('.typography-infoTableValue') | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders links', () => { | ||
const value = [{ | ||
type: 'row', | ||
children: [ | ||
{ | ||
type: 'label', | ||
children: [ | ||
{text: ''} | ||
] | ||
}, | ||
{ | ||
type: 'value', | ||
children: [ | ||
{text: 'Find more '}, | ||
{ | ||
type: 'link', | ||
href: 'https://example.com', | ||
children: [ | ||
{text: 'here'} | ||
] | ||
}, | ||
{text: '.'} | ||
] | ||
} | ||
] | ||
}]; | ||
|
||
const {getByRole} = render(<EditableTable value={value} />); | ||
|
||
expect(getByRole('link')).toHaveTextContent('here') | ||
expect(getByRole('link')).toHaveAttribute('href', 'https://example.com') | ||
expect(getByRole('link')).toHaveClass('typography-contentLink') | ||
expect(getByRole('link')).not.toHaveAttribute('target') | ||
expect(getByRole('link')).not.toHaveAttribute('rel') | ||
}); | ||
|
||
it('supports rendering links with target blank', () => { | ||
const value = [{ | ||
type: 'row', | ||
children: [ | ||
{ | ||
type: 'label', | ||
children: [ | ||
{text: ''} | ||
] | ||
}, | ||
{ | ||
type: 'value', | ||
children: [ | ||
{text: 'Find more '}, | ||
{ | ||
type: 'link', | ||
href: 'https://example.com', | ||
openInNewTab: true, | ||
children: [ | ||
{text: 'here'} | ||
] | ||
}, | ||
{text: '.'} | ||
] | ||
} | ||
] | ||
}]; | ||
|
||
const {getByRole} = render(<EditableTable value={value} />); | ||
|
||
expect(getByRole('link')).toHaveTextContent('here') | ||
expect(getByRole('link')).toHaveAttribute('target', '_blank') | ||
expect(getByRole('link')).toHaveAttribute('rel', 'noopener noreferrer') | ||
}); | ||
|
||
it('supports text formatting', () => { | ||
const value = [{ | ||
type: 'row', | ||
children: [ | ||
{ | ||
type: 'label', | ||
children: [ | ||
{text: ''} | ||
] | ||
}, | ||
{ | ||
type: 'value', | ||
children: [ | ||
{text: 'x', bold: true}, | ||
{text: '3', sup: true}, | ||
{text: ' and '}, | ||
{text: 'CO'}, | ||
{text: '2', sub: true} | ||
] | ||
} | ||
] | ||
}]; | ||
|
||
const {container} = render(<EditableTable value={value} />); | ||
|
||
expect(container.querySelector('strong')).toHaveTextContent('x') | ||
expect(container.querySelector('sup')).toHaveTextContent('3') | ||
expect(container.querySelector('sub')).toHaveTextContent('2') | ||
}); | ||
}); |
Oops, something went wrong.