Skip to content

Commit

Permalink
Achievements Page Mobile View (#2868)
Browse files Browse the repository at this point in the history
* updated for mobile

* fixed formatting

* ran test suites

* minor achievement card changes

* Revert snapshot change

* Remove committed temporary file

* Revert unnecessary changes

* Remove test coverage file

* reverted tsconfig change

* made achievement card scrollable

* Removed additional div

* Add css to achivementcontrol so it would format the page properly

* fixed formatting issues

---------

Co-authored-by: Richard Dominick <[email protected]>
Co-authored-by: sayomaki <[email protected]>
  • Loading branch information
3 people committed Mar 28, 2024
1 parent 89add1c commit d671afe
Show file tree
Hide file tree
Showing 5 changed files with 485 additions and 53 deletions.
100 changes: 54 additions & 46 deletions src/commons/achievement/AchievementManualEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,53 +95,61 @@ const AchievementManualEditor: React.FC<Props> = props => {

return (
<div className="achievement-manual-editor">
<h3>User: </h3>
<UserSelect
filterable={true}
items={users}
itemRenderer={userRenderer}
itemPredicate={userPredicate}
onItemSelect={changeSelectedUser}
noResults={<MenuItem disabled={true} text="No matching user" />}
>
<Button
outlined={true}
text={selectedUser ? selectedUser.name || selectedUser.username : 'No User Selected'}
color="White"
<div className="editor-section">
<h3>User: </h3>
<UserSelect
filterable={true}
items={users}
itemRenderer={userRenderer}
itemPredicate={userPredicate}
onItemSelect={changeSelectedUser}
noResults={<MenuItem disabled={true} text="No matching user" />}
>
<Button
outlined={true}
text={selectedUser ? selectedUser.name || selectedUser.username : 'No User Selected'}
color="White"
/>
</UserSelect>
</div>

<div className="editor-section">
<h3>Goal: </h3>
<GoalSelect
filterable={true}
items={manualAchievements}
itemRenderer={goalRenderer}
itemPredicate={goalPredicate}
onItemSelect={changeGoal}
noResults={<MenuItem disabled={true} text="No matching goal" />}
>
<Button outlined={true} text={goal ? goal.text : 'No Goal Selected'} color="White" />
</GoalSelect>
</div>

<div className="editor-section">
<h3>Count: </h3>
<NumericInput
value={count}
min={0}
allowNumericCharactersOnly={true}
minorStepSize={null}
placeholder="Count"
onValueChange={changeCount}
/>
</UserSelect>

<h3>Goal: </h3>
<GoalSelect
filterable={true}
items={manualAchievements}
itemRenderer={goalRenderer}
itemPredicate={goalPredicate}
onItemSelect={changeGoal}
noResults={<MenuItem disabled={true} text="No matching goal" />}
>
<Button outlined={true} text={goal ? goal.text : 'No Goal Selected'} color="White" />
</GoalSelect>

<h3>Count: </h3>
<NumericInput
value={count}
min={0}
allowNumericCharactersOnly={true}
minorStepSize={null}
placeholder="Count"
onValueChange={changeCount}
/>

<h3> </h3>
<Button outlined={true} text="Update Goal" onClick={updateGoal} intent="primary" />

<h3> </h3>
<Checkbox
checked={viewHidden}
label="View Hidden Achievements"
onChange={() => changeViewHidden(!viewHidden)}
/>
</div>

<div className="editor-section">
<Button outlined={true} text="Update Goal" onClick={updateGoal} intent="primary" />
</div>

<div className="editor-section">
<Checkbox
checked={viewHidden}
label="View Hidden Achievements"
onChange={() => changeViewHidden(!viewHidden)}
/>
</div>
</div>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/commons/achievement/utils/AchievementInferencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class AchievementInferencer {
// finally, process the nodeList
this.processNodes();
this.normalizePositions(achievement.uuid, achievement.position);

return newUuid;
}

Expand Down
6 changes: 3 additions & 3 deletions src/pages/achievement/subcomponents/AchievementDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IconNames } from '@blueprintjs/icons';
import React, { useEffect, useMemo, useState } from 'react';
import { useDispatch } from 'react-redux';
import { Role } from 'src/commons/application/ApplicationTypes';
import { useSession, useTypedSelector } from 'src/commons/utils/Hooks';
import { useResponsive, useSession, useTypedSelector } from 'src/commons/utils/Hooks';

import AchievementFilter from '../../../commons/achievement/AchievementFilter';
import AchievementManualEditor from '../../../commons/achievement/AchievementManualEditor';
Expand Down Expand Up @@ -52,6 +52,7 @@ const AchievementDashboard: React.FC = () => {
// default nothing selected
const userIdState = useState<AchievementUser | undefined>(undefined);
const [selectedUser] = userIdState;
const { isMobileBreakpoint } = useResponsive();

const {
group,
Expand Down Expand Up @@ -156,8 +157,7 @@ const AchievementDashboard: React.FC = () => {
updateGoalProgress={handleUpdateGoalProgress}
/>
)}

<div className="achievement-main">
<div className={isMobileBreakpoint ? 'achievement-main-mobile' : 'achievement-main'}>
<div className="filter-container">
<AchievementFilter
filterState={filterState}
Expand Down
113 changes: 110 additions & 3 deletions src/styles/_achievementcontrol.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,97 @@
@extend %container;
width: $view-width + $default-spacing * 2;

.task {
.achievement-card {
border-radius: 0.3rem;
cursor: pointer;
display: flex;
align-items: center;
height: $card-height;
transition: box-shadow 0.2s ease-in-out;
width: $card-width;

padding: 0.5em;
column-gap: 0.5em;

.content {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
width: 100%;

.heading {
align-items: center;
display: flex;

> * {
margin: 0;
}
}

.details {
display: flex;
flex-direction: row;
font-size: 0.8em;

p {
margin: 0;
}

.deadline,
.xp {
align-items: center;
display: flex;
column-gap: 0.3em;
width: 100%;
}
}
}
}

.achievement-card:hover {
box-shadow: 0 0 10px black;
}

.prerequisite-container {
$shrink-factor: 0.9;
$line-width: 1em;
// remaining-width is the empty space between line and card
$remaining-width: math.div((1 - $shrink-factor) * $card-width - 2 * $line-width, 2);
$top-spacing: 0.2em;
$line-extension: 0.1em;

display: flex;
flex-direction: column;

.prerequisite {
display: flex;
flex-direction: row;
max-width: $card-width;

.dropdown-lines {
height: $top-spacing + $card-height + $remaining-width + $line-extension;
margin: -#{math.div($card-height, 1.6)} -#{$line-width + $remaining-width} 0
$line-width;
min-width: $line-width;
}

.achievement-card {
margin: $top-spacing 0 0 0;
transform: scale($shrink-factor);
}
}

.prerequisite:first-child {
.dropdown-lines {
height: $top-spacing + math.div($card-height, 2) + $remaining-width;
margin-top: 0;
}
}
}
}

.no-view {
align-items: center;
text-shadow: black 1px 1px;
Expand All @@ -84,20 +175,23 @@
}

.view {
border-radius: 1rem;
text-shadow: black 1px 1px;
color: white;
display: flex;
flex-direction: column;
margin: $default-spacing;
min-height: $view-height;
width: $view-width;
padding-bottom: 1rem;

.cover {
border-top-left-radius: 1rem;
border-top-right-radius: 1rem;
display: flex;
flex-direction: column;
height: $cover-height;
text-align: center;
width: $cover-width;
min-height: $cover-height;
min-width: $cover-width;

h1 {
margin: 0.5em auto 0;
Expand All @@ -117,6 +211,10 @@
}
}

.progress-header {
margin-left: 2rem;
}

.goal {
align-items: center;
display: flex;
Expand All @@ -143,6 +241,15 @@
}
}

.goal-progress {
width: 100%;
padding-right: 2.5em;

.progress {
margin-top: 5px;
}
}

p {
margin: 0;
padding: 0;
Expand Down
Loading

0 comments on commit d671afe

Please sign in to comment.