forked from input-output-hk/daedalus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/ddw-923-stake-pool-list-table-view-ad…
…justments
- Loading branch information
Showing
15 changed files
with
254 additions
and
89 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
24 changes: 24 additions & 0 deletions
24
source/renderer/app/components/sidebar/SidebarCategory.messages.ts
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,24 @@ | ||
import { defineMessages } from 'react-intl'; | ||
|
||
export const messages = defineMessages({ | ||
wallets: { | ||
id: 'sidebar.categoryTooltip.wallets', | ||
defaultMessage: '!!!Wallets', | ||
description: 'Text for the tooltip of wallets category', | ||
}, | ||
staking: { | ||
id: 'sidebar.categoryTooltip.staking', | ||
defaultMessage: '!!!Staking', | ||
description: 'Text for the tooltip of staking category', | ||
}, | ||
settings: { | ||
id: 'sidebar.categoryTooltip.settings', | ||
defaultMessage: '!!!Settings', | ||
description: 'Text for the tooltip of settings category', | ||
}, | ||
voting: { | ||
id: 'sidebar.categoryTooltip.voting', | ||
defaultMessage: '!!!Voting', | ||
description: 'Text for the tooltip of voting category', | ||
}, | ||
}); |
57 changes: 34 additions & 23 deletions
57
source/renderer/app/components/sidebar/SidebarCategory.tsx
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 |
---|---|---|
@@ -1,42 +1,53 @@ | ||
import React, { Component } from 'react'; | ||
// @ts-ignore ts-migrate(2305) FIXME: Module '"react"' has no exported member 'Node'. | ||
import type { Node } from 'react'; | ||
import React from 'react'; | ||
import SVGInline from 'react-svg-inline'; | ||
import { observer } from 'mobx-react'; | ||
import classNames from 'classnames'; | ||
import { camelCase } from 'lodash'; | ||
import { PopOver } from 'react-polymorph/lib/components/PopOver'; | ||
import { injectIntl } from 'react-intl'; | ||
import type { SidebarCategoryInfo } from '../../config/sidebarConfig'; | ||
import styles from './SidebarCategory.scss'; | ||
import { messages } from './SidebarCategory.messages'; | ||
import type { Intl } from '../../types/i18nTypes'; | ||
import { TOOLTIP_DELAY } from '../../config/timingConfig'; | ||
|
||
type Props = { | ||
category: SidebarCategoryInfo; | ||
intl: Intl; | ||
isActive: boolean; | ||
onClick: (...args: Array<any>) => any; | ||
content?: Node; | ||
content?: React.ReactNode; | ||
}; | ||
|
||
@observer | ||
class SidebarCategory extends Component<Props> { | ||
render() { | ||
const { category, isActive, onClick, content } = this.props; | ||
const { name, icon, route } = category; | ||
const className = camelCase(name); | ||
const componentStyles = classNames( | ||
styles.component, | ||
className, | ||
styles[className], | ||
{ | ||
[styles.active]: isActive, | ||
} | ||
); | ||
const iconClassName = classNames(styles.icon, styles[`${className}Icon`]); | ||
return ( | ||
function SidebarCategory({ | ||
category, | ||
intl, | ||
isActive, | ||
onClick, | ||
content, | ||
}: Props) { | ||
const { name, icon, route, tooltipTextId } = category; | ||
const className = camelCase(name); | ||
const componentStyles = classNames( | ||
styles.component, | ||
className, | ||
styles[className], | ||
isActive && styles.active | ||
); | ||
const iconClassName = classNames(styles.icon, styles[`${className}Icon`]); | ||
return ( | ||
<PopOver | ||
delay={TOOLTIP_DELAY} | ||
offset={[0, -20]} | ||
content={tooltipTextId && intl.formatMessage(messages[tooltipTextId])} | ||
placement="bottom" | ||
> | ||
<button className={componentStyles} onClick={() => onClick(route)}> | ||
<SVGInline svg={icon} className={iconClassName} /> | ||
{content} | ||
</button> | ||
); | ||
} | ||
</PopOver> | ||
); | ||
} | ||
|
||
export default SidebarCategory; | ||
export default injectIntl(observer(SidebarCategory)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,60 @@ | ||
import React, { Component } from 'react'; | ||
import React from 'react'; | ||
import SVGInline from 'react-svg-inline'; | ||
import classNames from 'classnames'; | ||
import { PopOver } from 'react-polymorph/lib/components/PopOver'; | ||
import { defineMessages, injectIntl } from 'react-intl'; | ||
import newsFeedIcon from '../../assets/images/top-bar/news-feed-icon.inline.svg'; | ||
import styles from './NewsFeedIcon.scss'; | ||
import type { Intl } from '../../types/i18nTypes'; | ||
import { TOOLTIP_DELAY } from '../../config/timingConfig'; | ||
|
||
type Props = { | ||
intl: Intl; | ||
onNewsFeedIconClick: (...args: Array<any>) => any; | ||
newsFeedIconClass?: string; | ||
hasNotification: boolean; | ||
hasUpdate: boolean; | ||
}; | ||
export default class NewsFeedIcon extends Component<Props> { | ||
render() { | ||
const { | ||
onNewsFeedIconClick, | ||
newsFeedIconClass, | ||
hasNotification, | ||
hasUpdate, | ||
} = this.props; | ||
const componentClasses = classNames([ | ||
styles.component, | ||
hasNotification && !hasUpdate ? styles.notificationDot : null, | ||
hasUpdate ? styles.updateDot : null, | ||
newsFeedIconClass, | ||
]); | ||
return ( | ||
<button className={componentClasses} onClick={onNewsFeedIconClick}> | ||
<SVGInline className={styles.icon} svg={newsFeedIcon} /> | ||
</button> | ||
); | ||
} | ||
|
||
const messages = defineMessages({ | ||
iconTooltip: { | ||
id: 'news.newsfeed.iconTooltip', | ||
defaultMessage: '!!!Newsfeed', | ||
description: 'Newsfeed', | ||
}, | ||
}); | ||
|
||
function NewsFeedIcon({ | ||
intl, | ||
onNewsFeedIconClick, | ||
newsFeedIconClass, | ||
hasNotification, | ||
hasUpdate, | ||
}: Props) { | ||
const buttonClasses = classNames([ | ||
styles.button, | ||
hasNotification && !hasUpdate && styles.notificationDot, | ||
hasUpdate && styles.updateDot, | ||
newsFeedIconClass, | ||
]); | ||
return ( | ||
<div className={styles.component}> | ||
<PopOver | ||
appendTo="parent" | ||
delay={TOOLTIP_DELAY} | ||
offset={[0, 0]} | ||
content={ | ||
<span className={styles.tooltip}> | ||
{intl.formatMessage(messages.iconTooltip)} | ||
</span> | ||
} | ||
> | ||
<button className={buttonClasses} onClick={onNewsFeedIconClick}> | ||
<SVGInline className={styles.icon} svg={newsFeedIcon} /> | ||
</button> | ||
</PopOver> | ||
</div> | ||
); | ||
} | ||
|
||
export default injectIntl(NewsFeedIcon); |
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
Oops, something went wrong.