Skip to content

Commit

Permalink
Merge pull request #642 from carloslancha/issue-641-href-to-viewtypes
Browse files Browse the repository at this point in the history
ViewType object accepts href | Fixes #641
  • Loading branch information
matuzalemsteles authored Feb 27, 2018
2 parents cc5b093 + 533c078 commit 4ab75fd
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/clay-dataset-display/demos/a11y.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ <h1 class="page-title">
views: [
{
contentRenderer: 'cards',
href: '#cards',
icon: 'cards2',
label: 'Cards',
schema: {
Expand Down
1 change: 1 addition & 0 deletions packages/clay-dataset-display/demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ <h1 class="page-title">
views: [
{
contentRenderer: 'cards',
href: '#cards',
icon: 'cards2',
label: 'Cards',
schema: {
Expand Down
1 change: 1 addition & 0 deletions packages/clay-dataset-display/src/ClayDatasetDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ ClayDatasetDisplay.STATE = {
Config.shapeOf({
active: Config.bool().value(false),
disabled: Config.bool().value(false),
href: Config.string(),
icon: Config.string().required(),
id: Config.string().required(),
label: Config.string().required(),
Expand Down
1 change: 1 addition & 0 deletions packages/clay-dataset-display/src/ClayDatasetDisplay.soy
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
active: bool,
contentRenderer: string,
disabled: bool,
href: string,
icon: string,
label: string,
schema: ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ let defaultConfig = {
views: [
{
contentRenderer: 'cards',
href: '#cards',
icon: 'cards2',
label: 'Cards',
schema: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay and change view o
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -1338,7 +1338,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay and change view o
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -2027,7 +2027,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay and change view o
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -2561,7 +2561,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with grouped item
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -3441,7 +3441,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and li
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -4438,7 +4438,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and li
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -5281,7 +5281,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and li
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -5634,7 +5634,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with items and se
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down Expand Up @@ -6973,7 +6973,7 @@ exports[`ClayDatasetDisplay should render a ClayDatasetDisplay with ungrouped it
<div class="dropdown-menu dropdown-menu-indicator-start" ref="menu">
<ul class="list-unstyled">
<li>
<a class=" dropdown-item">
<a class=" dropdown-item" href="#cards">
<div class="dropdown-item-indicator">
<svg aria-hidden="true" class="lexicon-icon lexicon-icon-cards2" focusable="false">
<title>cards2</title>
Expand Down
52 changes: 52 additions & 0 deletions packages/clay-management-toolbar/demos/a11y.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ <h4>Disabled State</h4>
</div>
</div>

<div class="row row-spacing">
<div class="col">
<h4>With links as viewTypes</h4>
<div id="link-view-types-block"></div>
</div>
</div>

<div class="row row-spacing">
<div class="col">
<h4>With Only Search</h4>
Expand Down Expand Up @@ -133,6 +140,26 @@ <h4>With search results bar with active state</h4>
},
];

const linkViewTypes= [
{
active: true,
href: '#list',
icon: 'list',
label: 'List',
},
{
disabled: true,
href: '#table',
icon: 'table',
label: 'Table',
},
{
href: '#card',
icon: 'cards2',
label: 'Card',
},
];

const spritemap = '../../../node_modules/clay/lib/images/icons/icons.svg';

//Default State
Expand Down Expand Up @@ -186,6 +213,31 @@ <h4>With search results bar with active state</h4>
},
'#disabled-block');

//Link View Types
new metal.ClayManagementToolbar({
creationMenu: {
items: [
{
href: '#1',
label: 'Add Content 1',
},
{
href: '#2',
label: 'Add Content 2',
}
]
},
filterItems: filterItems,
searchFormName: 'mySearchName',
searchInputName: 'mySearchInputName',
selectable: true,
showInfoButton: true,
sortingOrder: 'asc',
spritemap: spritemap,
viewTypes: linkViewTypes,
},
'#link-view-types-block');

//With Only Search
new metal.ClayManagementToolbar({
searchFormName: 'mySearchName',
Expand Down
52 changes: 52 additions & 0 deletions packages/clay-management-toolbar/demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ <h4>Disabled State</h4>
</div>
</div>

<div class="row row-spacing">
<div class="col">
<h4>With links as viewTypes</h4>
<div id="link-view-types-block"></div>
</div>
</div>

<div class="row row-spacing">
<div class="col">
<h4>With Only Search</h4>
Expand Down Expand Up @@ -206,6 +213,26 @@ <h4>With search results bar with active state</h4>
},
];

const linkViewTypes= [
{
active: true,
href: '#list',
icon: 'list',
label: 'List',
},
{
disabled: true,
href: '#table',
icon: 'table',
label: 'Table',
},
{
href: '#card',
icon: 'cards2',
label: 'Card',
},
];

const spritemap = '../../../node_modules/clay/lib/images/icons/icons.svg';

//Default State
Expand Down Expand Up @@ -259,6 +286,31 @@ <h4>With search results bar with active state</h4>
},
'#disabled-block');

//Link View Types
new metal.ClayManagementToolbar({
creationMenu: {
items: [
{
href: '#1',
label: 'Add Content 1',
},
{
href: '#2',
label: 'Add Content 2',
}
]
},
filterItems: filterItems,
searchFormName: 'mySearchName',
searchInputName: 'mySearchInputName',
selectable: true,
showInfoButton: true,
sortingOrder: 'asc',
spritemap: spritemap,
viewTypes: linkViewTypes,
},
'#link-view-types-block');

//With Only Search
new metal.ClayManagementToolbar({
searchFormName: 'mySearchName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ ClayManagementToolbar.STATE = {
Config.shapeOf({
active: Config.bool().value(false),
disabled: Config.bool().value(false),
href: Config.string(),
icon: Config.string().required(),
label: Config.string().required(),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
{@param? viewTypes: list<[
active: bool,
disabled: bool,
href: string,
icon: string,
label: string
]>}
Expand Down Expand Up @@ -348,6 +349,7 @@
{@param? viewTypes: list<[
active: bool,
disabled: bool,
href: string,
icon: string,
label: string
]>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,33 @@ describe('ClayManagementToolbar', function() {
expect(managementToolbar).toMatchSnapshot();
});

it('should render a management toolbar with links as view types', () => {
managementToolbar = new ClayManagementToolbar({
spritemap: spritemap,
viewTypes: [
{
active: true,
href: '#list',
icon: 'list',
label: 'List',
},
{
disabled: true,
href: '#table',
icon: 'table',
label: 'Table',
},
{
href: '#cards',
icon: 'cards2',
label: 'Card',
},
],
});

expect(managementToolbar).toMatchSnapshot();
});

it('should render a managment toolbar with plus button', () => {
managementToolbar = new ClayManagementToolbar({
spritemap: spritemap,
Expand Down
Loading

0 comments on commit 4ab75fd

Please sign in to comment.