Skip to content

Commit

Permalink
Mobile displays for role cards
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Sep 29, 2023
1 parent 491dc49 commit 2c5a493
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 31 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ http://localhost:8080/ui/swagger-ui/index.html

http://localhost:8081/

http://localhost:4000/profile
http://localhost:4000

http://localhost:3000

### [Institution Admin](#institution-admin)

To become an institution admin in invite, add the following values as `eduPersonEntitlements` using Mujina:
* urn:mace:surfnet.nl:surfnet.nl:sab:organizationGUID:ad93daef-0911-e511-80d0-005056956c1a
* urn:mace:surfnet.nl:surfnet.nl:sab:role:SURFconextverantwoordelijke
8 changes: 4 additions & 4 deletions client/src/components/MoreLessText.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import "./MoreLessText.scss";
import I18n from "../locale/I18n";
import {isEmpty, stopEvent} from "../utils/Utils";

export const MoreLessText = ({txt, type = "full"}) => {
export const MoreLessText = ({txt, cutOffNumber = 190, type = "full"}) => {

const [showMore, setShowMore] = useState(!isEmpty(txt) && txt.length > 190
&& txt.substring(190).indexOf(" ") > -1);
const [showMore, setShowMore] = useState(!isEmpty(txt) && txt.length > cutOffNumber
&& txt.substring(cutOffNumber).indexOf(" ") > -1);
const [showLess, setShowLess] = useState(false);

const toggleShowMore = e => {
Expand All @@ -16,7 +16,7 @@ export const MoreLessText = ({txt, type = "full"}) => {
setShowLess(isShowingMore);
}

const txtToDisplay = isEmpty(txt) ? txt : txt.substring(0, 190 + txt.substring(190).indexOf(" "));
const txtToDisplay = isEmpty(txt) ? txt : txt.substring(0, cutOffNumber + txt.substring(cutOffNumber).indexOf(" "));

return (
<span className={`more-less-txt description ${type}`}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/RoleCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const RoleCard = ({role, index, invitationSelected, invitationSelectCallb
<section className={"user-role-info"}>
<p>{application.data.metaDataFields[`name:${I18n.locale}`]} ({application.data.metaDataFields[`OrganizationName:${I18n.locale}`]})</p>
<h3>{role.name}</h3>
<MoreLessText txt={role.description}/>
<MoreLessText txt={role.description} cutOffNumber={80}/>
</section>
{isEmpty(invitationSelected) && <div className={"launch"}>
<Button txt={I18n.t("inviter.details")} onClick={() => navigate(`/roles/${role.id}`)}/>
Expand Down
8 changes: 7 additions & 1 deletion client/src/components/RoleCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
display: flex;
align-items: center;

@media (max-width: 680px) {
@media (max-width: $medium) {
flex-direction: column;
align-items: flex-start;
}

.sds--checkbox-container {
Expand All @@ -73,6 +74,11 @@
.launch {
margin-left: auto;

button {
min-width: 140px;
margin-left: 15px;
}

@media (max-width: 680px) {
margin: 20px auto 0 0;
}
Expand Down
8 changes: 2 additions & 6 deletions client/src/components/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import I18n from "../locale/I18n";
import Logo from "./Logo";
import {Card, CardType} from "@surfnet/sds";
import {isEmpty} from "../utils/Utils";
import {RoleMetaData} from "./RoleMetaData";
import {deriveRemoteApplicationAttributes, providerInfo} from "../utils/Manage";
import {ReactComponent as SearchIcon} from "@surfnet/sds/icons/functional-icons/search.svg";
import {MoreLessText} from "./MoreLessText";
import {RoleCard} from "./RoleCard";

export const User = ({user, other}) => {
const searchRef = useRef();
Expand Down Expand Up @@ -78,11 +78,7 @@ export const User = ({user, other}) => {
const children =
<div key={index} className={"user-role"}>
<Logo src={logo} alt={"provider"} className={"provider"}/>
<section className={"user-role-info"}>
<h3>{role.name}</h3>
<MoreLessText txt={role.description}/>
<RoleMetaData role={role} user={user} provider={provider}/>
</section>
<RoleCard role={role} index={index} key={index}/>
</div>;
return (
<Card cardType={CardType.Big} children={children}/>
Expand Down
4 changes: 2 additions & 2 deletions client/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ body:after {
$min-width-pixels: 620px;

.sds--card--big {
min-width: $min-width-pixels;
width: $min-width-pixels;
@media (max-width: 680px) {
min-width: initial;
width: 90vw;
}
}

Expand Down
10 changes: 10 additions & 0 deletions client/src/pages/Inviter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@
display: grid;
grid-template-columns: repeat(3, 1fr);
margin-bottom: 40px;
@media (max-width: $medium) {
gap: 20px;
}

button {
grid-column-start: 2;
@media (max-width: $medium) {
grid-column-start: 1;
grid-column: span 2;
}
}

.history {
grid-column-start: 3;
display: flex;
Expand All @@ -48,6 +57,7 @@

}
}

.sub-info {
margin-bottom: 15px;
}
Expand Down
8 changes: 4 additions & 4 deletions welcome/src/components/MoreLessText.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import "./MoreLessText.scss";
import I18n from "../locale/I18n";
import {isEmpty, stopEvent} from "../utils/Utils";

export const MoreLessText = ({txt}) => {
export const MoreLessText = ({txt, cutOffNumber = 190}) => {

const [showMore, setShowMore] = useState(!isEmpty(txt) && txt.length > 190
&& txt.substring(190).indexOf(" ") > -1);
const [showMore, setShowMore] = useState(!isEmpty(txt) && txt.length > cutOffNumber
&& txt.substring(cutOffNumber).indexOf(" ") > -1);
const [showLess, setShowLess] = useState(false);

const toggleShowMore = e => {
Expand All @@ -16,7 +16,7 @@ export const MoreLessText = ({txt}) => {
setShowLess(isShowingMore);
}

const txtToDisplay = isEmpty(txt) ? txt : txt.substring(0, 190 + txt.substring(190).indexOf(" "));
const txtToDisplay = isEmpty(txt) ? txt : txt.substring(0, cutOffNumber + txt.substring(cutOffNumber).indexOf(" "));
return (
<span className={"more-less-txt description"}>
{showMore ? txtToDisplay : txt}
Expand Down
2 changes: 1 addition & 1 deletion welcome/src/components/RoleCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const RoleCard = ({role, index, isNew = false, skipLaunch= false}) => {
<section className={"user-role-info"}>
<p>{application.data.metaDataFields[`name:${I18n.locale}`]} ({application.data.metaDataFields[`OrganizationName:${I18n.locale}`]})</p>
<h3>{role.name}</h3>
<MoreLessText txt={role.description}/>
<MoreLessText txt={role.description} cutOffNumber={120}/>
</section>
{!skipLaunch && <div className={"launch"}>
<Button txt={I18n.t("proceed.launch")} onClick={() => {
Expand Down
8 changes: 7 additions & 1 deletion welcome/src/components/RoleCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
position: absolute;
top: -16px;
left: -22px;

@media (max-width: $medium) {
left: -10px;
}

}

@keyframes glow {
Expand Down Expand Up @@ -40,8 +45,9 @@
display: flex;
align-items: center;

@media (max-width: 680px) {
@media (max-width: $medium) {
flex-direction: column;
align-items: flex-start;
}

img, svg {
Expand Down
2 changes: 1 addition & 1 deletion welcome/src/components/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const User = ({user, invitationRoles = []}) => {
const renderUserRole = (userRole, index) => {
const role = userRole.role;
return (
<RoleCard role={role} index={index}/>
<RoleCard role={role} key={index} index={index}/>
);
}
const rolesToExclude = invitationRoles.map(invitationRole => invitationRole.role.id);
Expand Down
21 changes: 14 additions & 7 deletions welcome/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
@import "styles/tooltip";
@import "styles/forms";
@import "styles/vars";

$min-width-pixels: 620px;

.sds--toaster{
min-width: $min-width-pixels;
.sds--toaster {
width: $min-width-pixels;
margin: 25px 0;
@media (max-width: 680px) {
min-width: initial;
@media (max-width: $medium) {
width: 90vw;
}
}

.sds--card--big {
min-width: $min-width-pixels;
@media (max-width: 680px) {
min-width: initial;
width: $min-width-pixels;
@media (max-width: $medium) {
width: 90vw;
}
}

.sds--modal--container.full {
@media (max-width: $medium) {
width: 90vw;
}

}
5 changes: 3 additions & 2 deletions welcome/src/pages/Proceed.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const Proceed = () => {
const [showModal, setShowModal] = useState(true);

useEffect(() => {

if (isEmpty(user)) {
login(config);
} else if (isEmpty(invitation)) {
Expand All @@ -46,7 +47,7 @@ export const Proceed = () => {
const renderInvitationRole = (invitationRole, index, isNew, skipLaunch=false) => {
const role = invitationRole.role;
return (
<RoleCard role={role} index={index} isNew={isNew} skipLaunch={skipLaunch}/>
<RoleCard role={role} key={index} index={index} isNew={isNew} skipLaunch={skipLaunch}/>
);
}

Expand All @@ -73,7 +74,7 @@ export const Proceed = () => {
large={true}
children={toasterChildren}/>
{reloadedInvitation.roles.map((invitationRole, index) => renderInvitationRole(invitationRole, index, true))}
<User user={user} invitationRoles={invitation.roles}/>
<User user={user} invitationRoles={reloadedInvitation.roles}/>
</div>

</>
Expand Down

0 comments on commit 2c5a493

Please sign in to comment.