Skip to content

Commit

Permalink
Merge pull request #7302 from TheThingsNetwork/fix/console-redesign-i…
Browse files Browse the repository at this point in the history
…ssues

Fix console redesign issues
  • Loading branch information
PavelJankoski authored Oct 3, 2024
2 parents 3d00b5e + f50d3c8 commit 4d8571b
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 39 deletions.
23 changes: 21 additions & 2 deletions pkg/webui/components/button/button.styl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
width: 2.5rem
height: 2.5rem

&.primary
&.primary:not(.naked)
color: var(--c-bg-neutral-min)
background-color: var(--c-text-brand-normal)

Expand Down Expand Up @@ -159,7 +159,7 @@
gradient-border(var(--c-bg-neutral-min-hover), var(--c-gradient-neutral-light-01), var(--c-gradient-neutral-light-02))
box-shadow: none

&.naked
&.naked:not(.primary)
color: var(--c-text-neutral-light)

&:disabled
Expand All @@ -177,6 +177,25 @@
&:active
background-color: var(--c-bg-neutral-semilight)

&.primary.naked
color: var(--c-bg-brand-normal)

&:disabled
color: var(--c-bg-brand-normal-disabled)

&:not(:disabled)
&:hover
background-color: var(--c-bg-brand-semilight)
color: var(--c-bg-brand-normal-hover)

+focus-visible()
background-color: var(--c-bg-brand-semilight)
color: var(--c-bg-brand-normal-hover)

&:active
background-color: var(--c-bg-brand-semilight)
color: var(--c-bg-brand-normal-hover)

&.small
border-radius: $br.s

Expand Down
26 changes: 20 additions & 6 deletions pkg/webui/components/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const assembleClassnames = ({
primary,
secondary,
naked,
grey,
icon,
small,
busy,
Expand All @@ -57,7 +56,6 @@ const assembleClassnames = ({
[style.secondary]: secondary,
[style.naked]: naked,
[style.busy]: busy,
[style.grey]: grey,
[style.small]: small,
[style.withIcon]: icon !== undefined && message,
[style.noDropdownIcon]: noDropdownIcon,
Expand All @@ -68,20 +66,33 @@ const assembleClassnames = ({
})

const buttonChildren = props => {
const { dropdownItems, icon, busy, message, messageValues, noDropdownIcon, children, small } =
props
const {
dropdownItems,
icon,
busy,
message,
messageValues,
noDropdownIcon,
children,
small,
large,
} = props

const content = (
<>
{icon && <Icon className={style.icon} icon={icon} size={small ? 16 : 18} />}
{icon && <Icon className={style.icon} icon={icon} size={small ? 16 : large ? 24 : 18} />}
{message && (
<Message content={message} values={messageValues} className={style.linkButtonMessage} />
)}
{children}
{dropdownItems && (
<>
{!noDropdownIcon && (
<Icon className={style.expandIcon} icon={IconChevronDown} size={small ? 12 : 18} />
<Icon
className={style.expandIcon}
icon={IconChevronDown}
size={small ? 12 : large ? 22 : 18}
/>
)}
</>
)}
Expand Down Expand Up @@ -321,6 +332,8 @@ const commonPropTypes = {
dropdownItems: PropTypes.node,
/** A flag specifying whether the small styling should applied to the button. */
small: PropTypes.bool,
/** A flag specifying whether the large styling should applied to the button. */
large: PropTypes.bool,
}

buttonChildren.propTypes = {
Expand All @@ -342,6 +355,7 @@ buttonChildren.defaultProps = {
messageValues: undefined,
children: null,
small: false,
large: false,
}

Button.propTypes = {
Expand Down
4 changes: 2 additions & 2 deletions pkg/webui/components/link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ const Link = React.forwardRef((props, ref) => {

if (disabled) {
return (
<span className={classnames(classNames, style.disabled)} role={role}>
<button className={classnames(classNames, style.disabled)} disabled={disabled} role={role}>
{children}
</span>
</button>
)
}

Expand Down
16 changes: 10 additions & 6 deletions pkg/webui/components/link/link.styl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
&.primary
color: var(--c-text-brand-normal)

&:active:not(.disabled),
&:hover:not(.disabled)
&:active:not(:disabled),
&:hover:not(:disabled)
color: var(--c-text-brand-normal-hover)
text-decoration: underline

Expand All @@ -35,18 +35,22 @@

&.secondary
color: var(--c-text-neutral-light)
&:active:not(.disabled),
&:hover:not(.disabled)
&:active:not(:disabled),
&:hover:not(:disabled)
color: var(--c-text-neutral-heavy)

&.link-visited
&:visited
color: var(--c-text-neutral-heavy)

&:disabled
cursor: not-allowed !important
background: transparent
border: none

&.primary, &.secondary
&.disabled
&:disabled
opacity: .5
cursor: not-allowed

.doc-link
align-items: center
Expand Down
1 change: 0 additions & 1 deletion pkg/webui/components/map/widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import style from './widget.styl'

const Map = ({ id, markers, setupLocationLink, panel }) => {
const leafletConfig = {
zoomControl: false,
zoom: 10,
minZoom: 1,
}
Expand Down
44 changes: 31 additions & 13 deletions pkg/webui/components/panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import React from 'react'
import classnames from 'classnames'

import Icon, { IconArrowUpRight } from '@ttn-lw/components/icon'
import Button from '@ttn-lw/components/button'

import Message from '@ttn-lw/lib/components/message'

import PropTypes from '@ttn-lw/lib/prop-types'

import Icon from '../icon'
import Link from '../link'

import Toggle from './toggle'
Expand Down Expand Up @@ -58,6 +60,7 @@ const Panel = ({
divider,
shortCutLinkTarget,
shortCutLinkDisabled,
shortCutLinkButton,
compact,
}) => (
<div
Expand All @@ -81,17 +84,30 @@ const Panel = ({
{toggleOptions ? (
<Toggle options={toggleOptions} active={activeToggle} onToggleChange={onToggleClick} />
) : (
shortCutLinkTitle && (
<Link
primary
to={shortCutLinkPath}
className={styles.panelButton}
target={shortCutLinkTarget}
disabled={shortCutLinkDisabled}
>
<Message content={shortCutLinkTitle} />
</Link>
)
<>
{shortCutLinkButton && !shortCutLinkTitle && (
<Button.Link
to={shortCutLinkPath}
target={shortCutLinkTarget}
disabled={shortCutLinkDisabled}
icon={IconArrowUpRight}
primary
naked
large
/>
)}
{shortCutLinkTitle && !shortCutLinkButton && (
<Link
primary
to={shortCutLinkPath}
className={styles.panelButton}
target={shortCutLinkTarget}
disabled={shortCutLinkDisabled}
>
<Message content={shortCutLinkTitle} />
</Link>
)}
</>
)}
</div>
)}
Expand All @@ -111,6 +127,7 @@ Panel.propTypes = {
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
onToggleClick: PropTypes.func,
shortCutLinkButton: PropTypes.bool,
shortCutLinkDisabled: PropTypes.bool,
shortCutLinkPath: PropTypes.string,
shortCutLinkTarget: PropTypes.string,
Expand All @@ -130,7 +147,8 @@ Panel.defaultProps = {
compact: false,
messageDecorators: undefined,
divider: false,
shortCutLinkDisabled: undefined,
shortCutLinkDisabled: false,
shortCutLinkButton: false,
shortCutLinkPath: undefined,
shortCutLinkTitle: undefined,
shortCutLinkTarget: undefined,
Expand Down
7 changes: 0 additions & 7 deletions pkg/webui/components/panel/panel.styl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,3 @@
color: var(--c-bg-brand-normal)
font-variation-settings: 'FILL' 1

@container panel (max-width: 300px)
.panel-header
flex-direction: column
align-items: flex-start

.panel-button
align-self: flex-start
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
flex-direction: column
position: relative

& > :first-child
flex-wrap: nowrap

.content
display: flex
flex-direction: column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const BlurryNocMetricsPanel = ({ title, icon }) => {
<Panel
title={title}
icon={icon}
shortCutLinkTitle={sharedMessages.nocShortened}
shortCutLinkButton
shortCutLinkPath="#"
className={style.panel}
compact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TotalEndDevicesUpsellerPanel = () => {
<Panel
title={sharedMessages.totalEndDevices}
icon={IconDevice}
shortCutLinkTitle={sharedMessages.nocShortened}
shortCutLinkButton
shortCutLinkPath="#"
shortCutLinkDisabled
className={style.panel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
flex-direction: column
position: relative

& > :first-child
flex-wrap: nowrap

.content
display: flex
flex-direction: column
Expand Down
2 changes: 2 additions & 0 deletions pkg/webui/styles/variables/tokens.styl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ $tokens = {

'bg-brand-extralight': $c.tts-025, // Background for navigation elements background.
'bg-brand-light': $c.tts-050, // ?
'bg-brand-semilight': $c.tts-075, // ?
'bg-brand-normal': $c.tts-500, // Background for highlight elements.
'bg-brand-normal-hover': $c.tts-600, // Background for highlight elements on hover.

Expand Down Expand Up @@ -74,6 +75,7 @@ $tokens = {
'bg-warning-normal-disabled': $c.warning-200, // Background for warning highlight elements on disabled.
'bg-error-normal-disabled': $c.error-200, // Background for error highlight elements on disabled.
'bg-info-normal-disabled': $c.information-200, // Background for info highlight elements on disabled.
'bg-brand-normal-disabled': $c.tts-200, // Background for brand elements on disabled.

// TEXT COLORS
// ===========
Expand Down

0 comments on commit 4d8571b

Please sign in to comment.