diff --git a/app/javascript/flavours/glitch/components/badge.jsx b/app/javascript/flavours/glitch/components/badge.jsx new file mode 100644 index 0000000000..cf225a6a0c --- /dev/null +++ b/app/javascript/flavours/glitch/components/badge.jsx @@ -0,0 +1,34 @@ +import PropTypes from 'prop-types'; + +import { FormattedMessage } from 'react-intl'; + +import { ReactComponent as GroupsIcon } from '@material-symbols/svg-600/outlined/group.svg'; +import { ReactComponent as PersonIcon } from '@material-symbols/svg-600/outlined/person.svg'; +import { ReactComponent as SmartToyIcon } from '@material-symbols/svg-600/outlined/smart_toy.svg'; + + +export const Badge = ({ icon, label, domain }) => ( +
+ {icon} + {label} + {domain && {domain}} +
+); + +Badge.propTypes = { + icon: PropTypes.node, + label: PropTypes.node, + domain: PropTypes.node, +}; + +Badge.defaultProps = { + icon: , +}; + +export const GroupBadge = () => ( + } label={} /> +); + +export const AutomatedBadge = () => ( + } label={} /> +); diff --git a/app/javascript/flavours/glitch/features/account/components/header.jsx b/app/javascript/flavours/glitch/features/account/components/header.jsx index c2b827d9e1..1da9cb4411 100644 --- a/app/javascript/flavours/glitch/features/account/components/header.jsx +++ b/app/javascript/flavours/glitch/features/account/components/header.jsx @@ -10,6 +10,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { Avatar } from 'flavours/glitch/components/avatar'; +import { Badge, AutomatedBadge, GroupBadge } from 'flavours/glitch/components/badge'; import { Button } from 'flavours/glitch/components/button'; import { Icon } from 'flavours/glitch/components/icon'; import { IconButton } from 'flavours/glitch/components/icon_button'; @@ -308,20 +309,17 @@ class Header extends ImmutablePureComponent { const acct = isLocal && domain ? `${account.get('acct')}@${domain}` : account.get('acct'); const isIndexable = !account.get('noindex'); - let badge; + const badges = []; if (account.get('bot')) { - badge = (
); + badges.push(); } else if (account.get('group')) { - badge = (
); - } else { - badge = null; + badges.push(); } - let role = null; - if (account.getIn(['roles', 0])) { - role = (
{account.getIn(['roles', 0, 'name'])}
); - } + account.get('roles', []).forEach((role) => { + badges.push({role.get('name')}} domain={domain} />); + }); return (
@@ -339,7 +337,6 @@ class Header extends ImmutablePureComponent {
@@ -356,13 +353,19 @@ class Header extends ImmutablePureComponent {

- {badge} + @{acct} {lockedIcon}

+ {badges.length > 0 && ( +
+ {badges} +
+ )} + {signedIn && } {!(suspended || hidden) && ( diff --git a/app/javascript/flavours/glitch/styles/accounts.scss b/app/javascript/flavours/glitch/styles/accounts.scss index b0fe21bcf1..f31be33058 100644 --- a/app/javascript/flavours/glitch/styles/accounts.scss +++ b/app/javascript/flavours/glitch/styles/accounts.scss @@ -191,7 +191,6 @@ } } -.account-role, .information-badge, .simple_form .overridden, .simple_form .recommended, @@ -200,24 +199,55 @@ display: inline-block; padding: 4px 6px; cursor: default; - border-radius: 3px; + border-radius: 4px; font-size: 12px; line-height: 12px; font-weight: 500; color: $ui-secondary-color; - background-color: var(--user-role-background, rgba($ui-secondary-color, 0.1)); - border: 1px solid var(--user-role-border, rgba($ui-secondary-color, 0.5)); + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} - &.moderator { - color: $success-green; - background-color: rgba($success-green, 0.1); - border-color: rgba($success-green, 0.5); +.information-badge, +.simple_form .recommended, +.simple_form .not_recommended { + background-color: rgba($ui-secondary-color, 0.1); + border: 1px solid rgba($ui-secondary-color, 0.5); +} + +.account-role { + display: inline-flex; + padding: 4px; + padding-inline-end: 8px; + border: 1px solid $highlight-text-color; + color: $highlight-text-color; + font-weight: 500; + font-size: 12px; + letter-spacing: 0.5px; + line-height: 16px; + gap: 4px; + border-radius: 6px; + align-items: center; + + svg { + width: auto; + height: 15px; + opacity: 0.85; + fill: currentColor; } - &.admin { - color: lighten($error-red, 12%); - background-color: rgba(lighten($error-red, 12%), 0.1); - border-color: rgba(lighten($error-red, 12%), 0.5); + &__domain { + font-weight: 400; + opacity: 0.75; + letter-spacing: 0; + } +} + +.information-badge { + &.superapp { + background-color: rgba($success-green, 0.1); + border-color: rgba($success-green, 0.5); } } diff --git a/app/javascript/flavours/glitch/styles/components/accounts.scss b/app/javascript/flavours/glitch/styles/components/accounts.scss index 8983ed7ce4..21b61ec1c3 100644 --- a/app/javascript/flavours/glitch/styles/components/accounts.scss +++ b/app/javascript/flavours/glitch/styles/components/accounts.scss @@ -534,23 +534,25 @@ } } - &__tabs { + &__badges { display: flex; - align-items: flex-end; - justify-content: space-between; - padding: 7px 10px; - margin-top: -81px; - height: 130px; - overflow: hidden; - margin-inline-start: -2px; // aligns the pfp with content below + flex-wrap: wrap; + gap: 8px; .account-role { - margin: 0 2px; - padding: 4px 0; - box-sizing: border-box; - min-width: 90px; - text-align: center; + line-height: unset; } + } + + &__tabs { + display: flex; + align-items: flex-start; + justify-content: space-between; + padding: 7px 10px; + margin-top: -55px; + gap: 8px; + overflow: hidden; + margin-inline-start: -2px; // aligns the pfp with content below &__buttons { display: flex; @@ -579,10 +581,6 @@ &__name { padding: 5px 10px; - .account-role { - vertical-align: top; - } - .emojione { width: 22px; height: 22px;