-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added activity page layout * Changed input box sizing * Added progress bar component and help text * Added activity level indicator and translations * Added select initial selection side-effect * Prepared update to SDK 3.0.6 * Updated SDK to 3.0.5 and added functional open/close button * Split activity page into smaller components and added dynamic activity buttons * Made all activity page elements dynamic * Improved external link style * Added dynamic data to progress bar * Formatted code Co-authored-by: Frewacom <[email protected]>
- Loading branch information
Showing
35 changed files
with
755 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import clsx from 'clsx' | ||
import React from 'react' | ||
import { useTranslation, TFunction } from 'next-i18next' | ||
import { useActivity, Location, ActivityLevels } from '@nationskollen/sdk' | ||
|
||
export interface Props { | ||
location: Location | ||
} | ||
|
||
const ACTIVITY_COLORS: Record<ActivityLevels, string> = { | ||
[ActivityLevels.Closed]: 'bg-activity-closed', | ||
[ActivityLevels.Low]: 'bg-activity-low', | ||
[ActivityLevels.Medium]: 'bg-activity-medium', | ||
[ActivityLevels.High]: 'bg-activity-high', | ||
[ActivityLevels.VeryHigh]: 'bg-activity-very-high', | ||
[ActivityLevels.Full]: 'bg-activity-full', | ||
} | ||
|
||
const getActivityString = (level: ActivityLevels, t: TFunction) => { | ||
switch (level) { | ||
case ActivityLevels.Closed: | ||
return t('common:activity.level.closed') | ||
case ActivityLevels.Low: | ||
return t('common:activity.level.low') | ||
case ActivityLevels.Medium: | ||
return t('common:activity.level.medium') | ||
case ActivityLevels.High: | ||
return t('common:activity.level.high') | ||
case ActivityLevels.VeryHigh: | ||
return t('common:activity.level.very_high') | ||
case ActivityLevels.Full: | ||
return t('common:activity.level.full') | ||
} | ||
} | ||
|
||
const ActivityLevel = ({ location }: Props) => { | ||
const { t } = useTranslation('common') | ||
const { level } = useActivity(location.id, { level: location.activity_level }) | ||
const color = ACTIVITY_COLORS[level] | ||
|
||
return ( | ||
<div className="flex flex-row items-center px-md"> | ||
<span className={clsx('relative w-2 h-2 rounded-full mr-sm', color)}> | ||
{level !== ActivityLevels.Closed && ( | ||
<span | ||
className={clsx( | ||
'absolute inset-0 w-full h-full rounded-full animate-ping', | ||
color | ||
)} | ||
/> | ||
)} | ||
</span> | ||
<p className="font-bold text-text-highlight">{getActivityString(level, t)}</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default ActivityLevel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.