-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rewrite MenuBar buttons (TECH-320) (#879)
* refactor: new MenuButton component to replace MUI buttons * refactor: menubar style js to css module Introduces a new custom component MenuButton to replace the old MUI buttons for Options, Download and Interpretations in the MenuBar. https://jira.dhis2.org/browse/TECH-320 Note: As the buttons needs to match the color scheme of FileMenu (@dhis2/d2-ui-file-menu), the colors aren't fetched from ui-core just yet. There's an inline comment with a TODO about this.
- Loading branch information
1 parent
7bc25f7
commit 45b3adb
Showing
9 changed files
with
105 additions
and
65 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
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
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
13 changes: 13 additions & 0 deletions
13
packages/app/src/components/MenuBar/styles/MenuBar.module.css
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,13 @@ | ||
.menuBar { | ||
background: var(--colors-white); | ||
display: flex; | ||
align-items: center; | ||
padding: 0 var(--spacers-dp8); | ||
height: 38px; | ||
} | ||
.updateButton { | ||
margin-right: var(--spacers-dp8); | ||
} | ||
.grow { | ||
flex: 1 1 0%; | ||
} |
22 changes: 0 additions & 22 deletions
22
packages/app/src/components/MenuBar/styles/MenuBar.style.js
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import PropTypes from '@dhis2/prop-types' | ||
import React from 'react' | ||
|
||
import styles from './styles/MenuButton.module.css' | ||
|
||
const MenuButton = ({ | ||
children, | ||
dataTest, | ||
disabled, | ||
name, | ||
onBlur, | ||
onClick, | ||
onFocus, | ||
}) => ( | ||
<button | ||
className={styles.menuButton} | ||
data-test={dataTest} | ||
disabled={disabled} | ||
name={name} | ||
onBlur={onBlur} | ||
onClick={onClick} | ||
onFocus={onFocus} | ||
> | ||
{children} | ||
</button> | ||
) | ||
|
||
MenuButton.propTypes = { | ||
children: PropTypes.node, | ||
dataTest: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
name: PropTypes.string, | ||
onBlur: PropTypes.func, | ||
onClick: PropTypes.func, | ||
onFocus: PropTypes.func, | ||
} | ||
|
||
export default MenuButton |
30 changes: 30 additions & 0 deletions
30
packages/app/src/components/MenuButton/styles/MenuButton.module.css
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,30 @@ | ||
/* TODO: Fetch the colors from ui-core, once the same is done for the FileMenu (@dhis2/d2-ui-file-menu) */ | ||
|
||
.menuButton { | ||
display: inline-flex; | ||
position: relative; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 15px; | ||
font-weight: 400; | ||
text-transform: none; | ||
padding: 6px 8px; | ||
color: #000000; /* var(--colors-grey900) */ | ||
min-width: 64px; | ||
box-sizing: border-box; | ||
line-height: 1.75; | ||
background: none; | ||
border: none; | ||
transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; | ||
} | ||
|
||
.menuButton:hover:enabled { | ||
background-color: rgba(0, 0, 0, 0.08); /* var(--colors-grey300) */ | ||
} | ||
|
||
.menuButton:disabled { | ||
color: #e0e0e0; /* var(--colors-grey400); */ | ||
} | ||
.menuButton:focus { | ||
outline: none; | ||
} |
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