From 28c4eca0af696ff039b90b8af57aa818df442edf Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 25 Sep 2024 18:36:19 +0200 Subject: [PATCH] Change responsive break points on navigation panel in web UI (#32034) --- .../mastodon/components/navigation_portal.tsx | 32 +++--- .../mastodon/features/account/navigation.jsx | 5 +- .../features/ui/components/column_link.jsx | 7 +- .../ui/components/navigation_panel.jsx | 105 ++++++++++-------- .../styles/mastodon/components.scss | 54 +++++---- 5 files changed, 112 insertions(+), 91 deletions(-) diff --git a/app/javascript/mastodon/components/navigation_portal.tsx b/app/javascript/mastodon/components/navigation_portal.tsx index 46f2c0bfacd..08f91ce18aa 100644 --- a/app/javascript/mastodon/components/navigation_portal.tsx +++ b/app/javascript/mastodon/components/navigation_portal.tsx @@ -4,22 +4,22 @@ import AccountNavigation from 'mastodon/features/account/navigation'; import Trends from 'mastodon/features/getting_started/containers/trends_container'; import { showTrends } from 'mastodon/initial_state'; -const DefaultNavigation: React.FC = () => - showTrends ? ( - <> -
- - - ) : null; +const DefaultNavigation: React.FC = () => (showTrends ? : null); export const NavigationPortal: React.FC = () => ( - - - - - - - - - +
+ + + + + + + + + +
); diff --git a/app/javascript/mastodon/features/account/navigation.jsx b/app/javascript/mastodon/features/account/navigation.jsx index ccebe9043a1..aa78135de24 100644 --- a/app/javascript/mastodon/features/account/navigation.jsx +++ b/app/javascript/mastodon/features/account/navigation.jsx @@ -43,10 +43,7 @@ class AccountNavigation extends PureComponent { } return ( - <> -
- - + ); } diff --git a/app/javascript/mastodon/features/ui/components/column_link.jsx b/app/javascript/mastodon/features/ui/components/column_link.jsx index 6ef122c07be..3386c17f071 100644 --- a/app/javascript/mastodon/features/ui/components/column_link.jsx +++ b/app/javascript/mastodon/features/ui/components/column_link.jsx @@ -3,11 +3,11 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import { useRouteMatch, NavLink } from 'react-router-dom'; -import { Icon } from 'mastodon/components/icon'; +import { Icon } from 'mastodon/components/icon'; -const ColumnLink = ({ icon, activeIcon, iconComponent, activeIconComponent, text, to, href, method, badge, transparent, ...other }) => { +const ColumnLink = ({ icon, activeIcon, iconComponent, activeIconComponent, text, to, href, method, badge, transparent, optional, ...other }) => { const match = useRouteMatch(to); - const className = classNames('column-link', { 'column-link--transparent': transparent }); + const className = classNames('column-link', { 'column-link--transparent': transparent, 'column-link--optional': optional }); const badgeElement = typeof badge !== 'undefined' ? {badge} : null; const iconElement = (typeof icon === 'string' || iconComponent) ? : icon; const activeIconElement = activeIcon ?? (activeIconComponent ? : iconElement); @@ -43,6 +43,7 @@ ColumnLink.propTypes = { method: PropTypes.string, badge: PropTypes.node, transparent: PropTypes.bool, + optional: PropTypes.bool, }; export default ColumnLink; diff --git a/app/javascript/mastodon/features/ui/components/navigation_panel.jsx b/app/javascript/mastodon/features/ui/components/navigation_panel.jsx index 0ca21e89765..8fa20a554d3 100644 --- a/app/javascript/mastodon/features/ui/components/navigation_panel.jsx +++ b/app/javascript/mastodon/features/ui/components/navigation_panel.jsx @@ -120,14 +120,17 @@ class NavigationPanel extends Component { let banner = undefined; - if(transientSingleColumn) - banner = (
- {intl.formatMessage(messages.openedInClassicInterface)} - {" "} - - {intl.formatMessage(messages.advancedInterface)} - -
); + if (transientSingleColumn) { + banner = ( +
+ {intl.formatMessage(messages.openedInClassicInterface)} + {" "} + + {intl.formatMessage(messages.advancedInterface)} + +
+ ); + } return (
@@ -141,54 +144,58 @@ class NavigationPanel extends Component {
} - {signedIn && ( - <> - - - - - )} +
+ {signedIn && ( + <> + + + + + )} - {trendsEnabled ? ( - - ) : ( - - )} + {trendsEnabled ? ( + + ) : ( + + )} - {(signedIn || timelinePreview) && ( - - )} + {(signedIn || timelinePreview) && ( + + )} - {!signedIn && ( -
+ {!signedIn && ( +
+
+ { disabledAccountId ? : } +
+ )} + + {signedIn && ( + <> + + + + + + + +
+ + + + {canManageReports(permissions) && } + {canViewAdminDashboard(permissions) && } + + )} + +

- { disabledAccountId ? : } +
- )} - - {signedIn && ( - <> - - - - - - - -
- - - - {canManageReports(permissions) && } - {canViewAdminDashboard(permissions) && } - - )} - -
-
-
+
+
); diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index ea163ff9bf5..847c594ae50 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -3490,12 +3490,14 @@ $ui-header-logo-wordmark-width: 99px; margin-top: 10px; margin-bottom: 10px; height: calc(100% - 20px); - overflow-y: auto; + overflow: hidden; display: flex; flex-direction: column; - & > a { - flex: 0 0 auto; + &__menu { + flex: 1 1 auto; + min-height: 0; + overflow-y: auto; } .logo { @@ -3506,6 +3508,36 @@ $ui-header-logo-wordmark-width: 99px; &__logo { margin-bottom: 12px; } + + @media screen and (height <= 710px) { + &__portal { + display: none; + } + } + + @media screen and (height <= 765px) { + &__portal .trends__item:nth-child(n + 3) { + display: none; + } + } + + @media screen and (height <= 820px) { + &__portal .trends__item:nth-child(n + 4) { + display: none; + } + } + + @media screen and (height <= 920px) { + .column-link.column-link--optional { + display: none; + } + } + + @media screen and (height <= 1040px) { + .list-panel { + display: none; + } + } } .navigation-panel, @@ -3869,22 +3901,6 @@ $ui-header-logo-wordmark-width: 99px; } } - @media screen and (height <= 810px) { - .trends__item:nth-of-type(3) { - display: none; - } - } - - @media screen and (height <= 720px) { - .trends__item:nth-of-type(2) { - display: none; - } - } - - @media screen and (height <= 670px) { - display: none; - } - .trends__item { border-bottom: 0; padding: 10px;