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: Show "more button" disabled instead of hiding it #323

Merged
merged 3 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2019-05-07T10:46:49.139Z\n"
"PO-Revision-Date: 2019-05-07T10:46:49.139Z\n"
"POT-Creation-Date: 2019-05-22T08:39:03.062Z\n"
"PO-Revision-Date: 2019-05-22T08:39:03.062Z\n"

msgid "Dashboard"
msgstr ""
Expand Down Expand Up @@ -41,10 +41,10 @@ msgstr ""
msgid "Search for a dashboard"
msgstr ""

msgid "Show less"
msgid "Show more"
msgstr ""

msgid "Show more"
msgid "Show less"
msgstr ""

msgid "No access"
Expand Down
11 changes: 5 additions & 6 deletions src/components/ControlBar/DashboardsBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ export class DashboardsBar extends Component {
/>
))}
</div>
{this.props.userRows !== MAX_ROW_COUNT ? (
<ShowMoreButton
onClick={this.onToggleMaxHeight}
isMaxHeight={this.state.isMaxHeight}
/>
) : null}
<ShowMoreButton
onClick={this.onToggleMaxHeight}
isMaxHeight={this.state.isMaxHeight}
disabled={this.props.userRows === MAX_ROW_COUNT}
/>
</ControlBar>
);
}
Expand Down
35 changes: 24 additions & 11 deletions src/components/ControlBar/ShowMoreButton.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
import React from 'react';
import i18n from '@dhis2/d2-i18n';
import { colors } from '@dhis2/ui-core';
import { withStyles } from '@material-ui/core/styles';

import { colors } from '../../modules/colors';

export const SHOWMORE_BAR_HEIGHT = 16;

const styles = {
showMore: {
color: colors.royalBlue,
color: colors.grey700,
cursor: 'pointer',
fontSize: 11,
fontWeight: 700,
fontWeight: 400,
height: SHOWMORE_BAR_HEIGHT,
paddingTop: 5,
textTransform: 'uppercase',
visibility: 'visible',
jenniferarnesen marked this conversation as resolved.
Show resolved Hide resolved
'&:hover': {
textDecoration: 'underline',
},
},
disabled: {
paddingTop: 5,
color: colors.grey700,
fontSize: 11,
cursor: 'not-allowed',
},
};

export const ShowMoreButton = ({ onClick, isMaxHeight, classes }) => (
<div style={{ textAlign: 'center' }}>
<div className={classes.showMore} onClick={onClick}>
{isMaxHeight ? i18n.t('Show less') : i18n.t('Show more')}
export const ShowMoreButton = ({ onClick, isMaxHeight, classes, disabled }) => {
return (
<div style={{ textAlign: 'center' }}>
{disabled ? (
<div className={classes.disabled}>{i18n.t('Show more')}</div>
) : (
<div className={classes.showMore} onClick={onClick}>
{isMaxHeight ? i18n.t('Show less') : i18n.t('Show more')}
</div>
)}
</div>
</div>
);
);
};

export default withStyles(styles)(ShowMoreButton);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Button } from '@dhis2/ui-core';
import DialogActions from '@material-ui/core/DialogActions';
import { ConfirmDeleteDialog } from '../ConfirmDeleteDialog';
import { getStubContext } from '../../../setupTests';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ ShallowWrapper {
/>
</div>
</div>,
null,
<WithStyles(ShowMoreButton)
disabled={true}
isMaxHeight={true}
onClick={[Function]}
/>,
],
"editMode": false,
"height": 424,
Expand Down Expand Up @@ -169,7 +173,19 @@ ShallowWrapper {
],
"type": "div",
},
null,
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": true,
"isMaxHeight": true,
"onClick": [Function],
},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Expand Down Expand Up @@ -210,7 +226,11 @@ ShallowWrapper {
/>
</div>
</div>,
null,
<WithStyles(ShowMoreButton)
disabled={true}
isMaxHeight={true}
onClick={[Function]}
/>,
],
"editMode": false,
"height": 424,
Expand Down Expand Up @@ -327,7 +347,19 @@ ShallowWrapper {
],
"type": "div",
},
null,
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": true,
"isMaxHeight": true,
"onClick": [Function],
},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Expand Down Expand Up @@ -426,6 +458,7 @@ ShallowWrapper {
</div>
</div>,
<WithStyles(ShowMoreButton)
disabled={false}
isMaxHeight={false}
onClick={[Function]}
/>,
Expand Down Expand Up @@ -550,6 +583,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": false,
"isMaxHeight": false,
"onClick": [Function],
},
Expand Down Expand Up @@ -598,6 +632,7 @@ ShallowWrapper {
</div>
</div>,
<WithStyles(ShowMoreButton)
disabled={false}
isMaxHeight={false}
onClick={[Function]}
/>,
Expand Down Expand Up @@ -722,6 +757,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": false,
"isMaxHeight": false,
"onClick": [Function],
},
Expand Down Expand Up @@ -827,6 +863,7 @@ ShallowWrapper {
</div>
</div>,
<WithStyles(ShowMoreButton)
disabled={false}
isMaxHeight={false}
onClick={[Function]}
/>,
Expand Down Expand Up @@ -951,6 +988,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": false,
"isMaxHeight": false,
"onClick": [Function],
},
Expand Down Expand Up @@ -999,6 +1037,7 @@ ShallowWrapper {
</div>
</div>,
<WithStyles(ShowMoreButton)
disabled={false}
isMaxHeight={false}
onClick={[Function]}
/>,
Expand Down Expand Up @@ -1123,6 +1162,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": false,
"isMaxHeight": false,
"onClick": [Function],
},
Expand Down Expand Up @@ -1254,6 +1294,7 @@ ShallowWrapper {
/>
</div>,
<WithStyles(ShowMoreButton)
disabled={false}
isMaxHeight={false}
onClick={[Function]}
/>,
Expand Down Expand Up @@ -1419,6 +1460,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": false,
"isMaxHeight": false,
"onClick": [Function],
},
Expand Down Expand Up @@ -1479,6 +1521,7 @@ ShallowWrapper {
/>
</div>,
<WithStyles(ShowMoreButton)
disabled={false}
isMaxHeight={false}
onClick={[Function]}
/>,
Expand Down Expand Up @@ -1644,6 +1687,7 @@ ShallowWrapper {
"key": undefined,
"nodeType": "class",
"props": Object {
"disabled": false,
"isMaxHeight": false,
"onClick": [Function],
},
Expand Down