Skip to content

Commit

Permalink
custom button bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyu2333 committed Sep 22, 2021
1 parent 327cdd8 commit 2818095
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "../../css/colors.css";

.profile-button {
.custom-button {
/* background: $data-primary; */
margin: 0 10px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import PropTypes from 'prop-types';
import React from 'react';
import Button from '../button/button.jsx';

import styles from './profile-button.css';
import styles from './custom-button.css';

const ProfileButton = ({
const CustomButton = ({
className,
style,
onClick,
Expand All @@ -15,23 +15,23 @@ const ProfileButton = ({
<Button
className={classNames(
className,
styles.profileButton
styles.customButton
)}
style={style}
onClick={onClick}
>
{buttonName ? buttonName: "个人中心"}
{buttonName}
</Button>
);

ProfileButton.propTypes = {
CustomButton.propTypes = {
className: PropTypes.string,
onClick: PropTypes.func,
buttonName: PropTypes.string
};

ProfileButton.defaultProps = {
CustomButton.defaultProps = {
onClick: () => {}
};

export default ProfileButton;
export default CustomButton;
10 changes: 6 additions & 4 deletions src/components/menu-bar/menu-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Box from '../box/box.jsx';
import Button from '../button/button.jsx';
import CommunityButton from './community-button.jsx';
import ShareButton from './share-button.jsx';
import ProfileButton from './profile-button.jsx';
import CustomButton from './custom-button.jsx';
import {ComingSoonTooltip} from '../coming-soon/coming-soon.jsx';
import Divider from '../divider/divider.jsx';
import LanguageSelector from '../../containers/language-selector.jsx';
Expand Down Expand Up @@ -620,7 +620,7 @@ class MenuBar extends React.Component {

<div className={classNames(styles.menuBarItem)}>
{
(window.scratchConfig && window.scratchConfig.profileButton && window.scratchConfig.profileButton.show) && (<ProfileButton
(window.scratchConfig && window.scratchConfig.profileButton && window.scratchConfig.profileButton.show) && (<CustomButton
className={styles.menuBarButton}
onClick = {
() => {
Expand All @@ -634,13 +634,15 @@ class MenuBar extends React.Component {
(window.scratchConfig && window.scratchConfig.menuBar && window.scratchConfig.menuBar.customButtons && window.scratchConfig.menuBar.customButtons.length>0) && (
window.scratchConfig.menuBar.customButtons.map(item=> {
if(item.show){
return <ProfileButton
return <CustomButton
key={item.buttonName}
className={styles.menuBarButton}
style={item.style || {}}
onClick = {() => {item.handleClick();}}
onClick = {item.handleClick}
buttonName = {item.buttonName}
/>
}else{
return ""
}
})
)
Expand Down

0 comments on commit 2818095

Please sign in to comment.