Skip to content

A platform for community discussion. Free, open, simple.

DEV: move mobile user card styles into common directory (#38984)

Krisb85e72db2d6b
diff --git a/app/assets/stylesheets/common/components/user-card.scss b/app/assets/stylesheets/common/components/user-card.scss
index dc2f83ec21e..694590bdb2c 100644
--- a/app/assets/stylesheets/common/components/user-card.scss
+++ b/app/assets/stylesheets/common/components/user-card.scss
@@ -1,4 +1,5 @@
@use "sass:math";
+@use "lib/viewport";
.fk-d-menu[data-identifier="usercard"] {
max-width: calc(100vw - 2em);
@@ -8,6 +9,12 @@
min-width: 0;
overflow: visible;
}
+
+ @include viewport.until(sm) {
+ &[data-content] {
+ z-index: z("max");
+ }
+ }
}
.animated-placeholder {
@@ -58,6 +65,12 @@
box-shadow: unset !important;
z-index: unset !important;
+ @include viewport.until(sm) {
+ box-sizing: border-box;
+ max-width: 95vw;
+ max-height: 85vh; // 2.5vh margin-top and margin-bottom. 10vh top
+ }
+
.card-content {
padding: 10px;
background: rgb(var(--secondary-rgb), 0.85);
@@ -85,9 +98,18 @@
// avatar - names - controls
.first-row {
+ @include viewport.until(sm) {
+ flex-wrap: wrap;
+ }
+
.names {
padding-left: 1.25em;
+ @include viewport.until(sm) {
+ box-sizing: border-box;
+ flex: 1 1 0;
+ }
+
.user-profile-link {
display: flex;
align-items: center;
@@ -114,6 +136,31 @@
list-style-type: none;
margin: 0;
+ @include viewport.until(sm) {
+ width: 100%; // always wraps to next line
+ display: flex;
+ flex-wrap: wrap;
+ margin-top: 1em;
+ gap: 0.5em;
+
+ li {
+ flex: 1 0 45%;
+ min-width: 8em;
+
+ &:empty {
+ display: none;
+ }
+
+ button {
+ margin: 0;
+
+ .d-button-label {
+ @include ellipsis;
+ }
+ }
+ }
+ }
+
button {
width: 100%;
}
@@ -127,16 +174,28 @@
.names__primary {
@include ellipsis;
line-height: var(--line-height-medium);
- font-size: var(--font-up-5);
+ font-size: var(--font-up-3);
font-weight: bold;
+ @include viewport.from(sm) {
+ font-size: var(--font-up-5);
+ }
+
.d-icon {
color: var(--primary);
+
+ @include viewport.until(sm) {
+ font-size: var(--font-down-2);
+ }
}
}
.names__secondary {
font-size: var(--font-up-1);
+
+ @include viewport.until(sm) {
+ font-size: var(--font-0);
+ }
}
.metadata {
@@ -191,6 +250,10 @@
max-height: var(--avatar-width);
position: relative;
+ @include viewport.until(sm) {
+ flex: 0 0 auto;
+ }
+
.own-avatar-pencil {
opacity: 0;
position: absolute;
@@ -330,6 +393,19 @@
margin: 0;
text-align: left;
+ @include viewport.until(sm) {
+ max-height: 40vh;
+ overflow-y: auto;
+
+ .public-user-field {
+ @include line-clamp(3);
+ }
+ }
+
+ @media screen and (height <= 550px) {
+ max-height: 12vh;
+ }
+
.user-field-value-list-item:not(:last-of-type) {
&::after {
// create comma separated list
@@ -345,12 +421,28 @@
flex-wrap: wrap;
gap: var(--space-1);
+ @include viewport.until(sm) {
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ }
+
.user-badge {
@include ellipsis;
background: var(--primary-very-low);
border: 1px solid var(--content-border-color);
color: var(--primary);
border-radius: var(--d-border-radius);
+
+ @include viewport.until(sm) {
+ display: flex;
+ margin: 0;
+ width: 100%;
+
+ .badge-display-name {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ }
}
.user-card-badge-link {
@@ -361,6 +453,16 @@
.more-user-badges {
vertical-align: top;
display: inline-block;
+
+ @include viewport.until(sm) {
+ display: flex;
+ box-sizing: border-box;
+
+ a {
+ width: 100%;
+ display: flex;
+ }
+ }
}
.more-user-badges a {
@@ -372,6 +474,10 @@
display: flex;
align-items: center;
+ @include viewport.until(sm) {
+ font-size: var(--font-down-1);
+ }
+
img.emoji {
margin-right: 0.3em;
}
@@ -442,3 +548,33 @@
}
}
}
+
+@include viewport.until(sm) {
+ .card-cloak {
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: z("mobile-composer") + 1; // 1101
+ height: 100vh;
+ width: 100vw;
+ background-color: #000;
+ opacity: 0;
+ visibility: hidden;
+ transition:
+ opacity 0.3s,
+ visibility 0s 0.3s;
+
+ &.--visible {
+ pointer-events: all;
+ opacity: 0.6;
+ visibility: visible;
+ transition:
+ opacity 0.3s,
+ visibility 0s;
+ }
+
+ @media (prefers-reduced-motion) {
+ transition-duration: 0s;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/mobile/components/_index.scss b/app/assets/stylesheets/mobile/components/_index.scss
index 14f535b6b82..7640dd17d44 100644
--- a/app/assets/stylesheets/mobile/components/_index.scss
+++ b/app/assets/stylesheets/mobile/components/_index.scss
@@ -1,2 +1 @@
-@import "user-card";
@import "emoji-picker";
diff --git a/app/assets/stylesheets/mobile/components/user-card.scss b/app/assets/stylesheets/mobile/components/user-card.scss
deleted file mode 100644
index d6784a35d85..00000000000
--- a/app/assets/stylesheets/mobile/components/user-card.scss
+++ /dev/null
@@ -1,140 +0,0 @@
-[data-content][data-identifier="usercard"] {
- z-index: z("max");
-}
-
-// shared styles for user and group cards
-.user-card,
-.group-card {
- max-width: 95vw;
- margin: 0;
- max-height: 85vh; // 2.5vh margin-top and margin-bottom. 10vh top
- box-sizing: border-box;
-
- // avatar - names - controls
- .first-row {
- flex-wrap: wrap;
-
- .names {
- flex: 1 1 0;
- box-sizing: border-box;
- }
-
- .user-card-avatar {
- flex: 0 0 auto;
- }
-
- .usercard-controls {
- width: 100%; // always wraps to next line
- display: flex;
- flex-wrap: wrap;
- margin-top: 1em;
- gap: 0.5em;
-
- li {
- flex: 1 0 45%;
- min-width: 8em;
-
- &:empty {
- display: none;
- }
-
- button {
- margin: 0;
-
- .d-button-label {
- @include ellipsis;
- }
- }
- }
- }
- }
-
- .names__primary {
- font-size: var(--font-up-3);
-
- .d-icon {
- font-size: var(--font-down-2);
- }
- }
-
- .names__secondary {
- font-size: var(--font-0);
- }
-
- .user-status {
- font-size: var(--font-down-1);
- }
-}
-
-// styles for user cards only
-.user-card {
- // badges
- .badge-section {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
-
- .user-card-badge-link,
- .more-user-badges {
- display: flex;
- box-sizing: border-box;
-
- a {
- width: 100%;
- display: flex;
- }
- }
-
- .user-badge {
- display: flex;
- margin: 0;
- width: 100%;
-
- .badge-display-name {
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- }
-
- .public-user-fields {
- max-height: 40vh;
- overflow-y: auto;
-
- @media screen and (height <= 550px) {
- max-height: 12vh;
- }
-
- .public-user-field {
- @include line-clamp(3);
- }
- }
-}
-
-// mobile card cloak
-.card-cloak {
- position: fixed;
- top: 0;
- left: 0;
- z-index: z("mobile-composer") + 1; // 1101
- height: 100vh;
- width: 100vw;
- background-color: #000;
- opacity: 0;
- visibility: hidden;
- transition:
- opacity 0.3s,
- visibility 0s 0.3s;
-
- &.--visible {
- pointer-events: all;
- opacity: 0.6;
- visibility: visible;
- transition:
- opacity 0.3s,
- visibility 0s;
- }
-
- @media (prefers-reduced-motion) {
- transition-duration: 0s;
- }
-}