-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dashboard-v4' into idr/speed-restrictions-api
- Loading branch information
Showing
40 changed files
with
201 additions
and
259 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
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 |
---|---|---|
@@ -1,67 +0,0 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import dayjs from 'dayjs'; | ||
import type { WidgetValueInterface } from '../../../types/basicWidgets'; | ||
|
||
import { LoadingSpinner } from '../../graphics/LoadingSpinner'; | ||
import { useDelimitatedRoute } from '../../../utils/router'; | ||
|
||
type SentimentDirection = 'positiveOnIncrease' | 'negativeOnIncrease'; | ||
|
||
export type BasicWidgetDataLayoutProps = { | ||
widgetValue: WidgetValueInterface; | ||
sentimentDirection?: SentimentDirection; | ||
}; | ||
|
||
export const SimpleDeltaWidget: React.FC<BasicWidgetDataLayoutProps> = ({ | ||
widgetValue, | ||
sentimentDirection = 'negativeOnIncrease', | ||
}) => { | ||
const { | ||
query: { startDate, endDate }, | ||
} = useDelimitatedRoute(); | ||
const getDelta = () => { | ||
const deltaValue = widgetValue.getFormattedDelta(); | ||
const increase = widgetValue.delta ? widgetValue.delta > 0 : false; | ||
const positiveSentiment = | ||
(!increase && sentimentDirection === 'negativeOnIncrease') || | ||
(increase && sentimentDirection === 'positiveOnIncrease'); | ||
const bgColor = positiveSentiment ? 'bg-green-100' : 'bg-red-100'; | ||
const textColor = positiveSentiment ? 'text-green-800' : 'text-red-800'; | ||
return ( | ||
<div className="flex flex-row gap-x-2"> | ||
<div className="flex flex-row items-baseline gap-x-1"> | ||
<div | ||
className={classNames( | ||
'mt-1 flex flex-row items-center rounded-full', | ||
widgetValue.delta ? bgColor : 'bg-gray-100', | ||
widgetValue.delta ? textColor : 'text-rb-800' | ||
)} | ||
> | ||
<p | ||
className={classNames('px-4 text-2xl', widgetValue.delta ? textColor : 'text-rb-800')} | ||
> | ||
{deltaValue} | ||
</p> | ||
</div> | ||
<p className="text-base text-design-subtitleGrey">{widgetValue.getUnits()}</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={classNames('relative flex flex-1 bg-white')}> | ||
{widgetValue.value === undefined && <LoadingSpinner isWidget />} | ||
<div className={classNames('flex flex-col items-start p-2')}> | ||
<p className={classNames('text-xs text-design-subtitleGrey sm:text-sm')}> | ||
{dayjs(startDate).format('MMM D, YYYY')} - {dayjs(endDate).format('MMM D, YYYY')} | ||
</p> | ||
<div className="flex flex-row items-baseline gap-x-1">{getDelta()}</div> | ||
<div className="flex flex-row items-baseline gap-x-1"></div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
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,7 @@ | ||
import React from 'react'; | ||
export interface UnitTextProps { | ||
text: string; | ||
} | ||
export const UnitText: React.FC<UnitTextProps> = ({ text }) => { | ||
return <span className="text-base text-design-subtitleGrey">{text}</span>; | ||
}; |
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,8 @@ | ||
import React from 'react'; | ||
|
||
export interface WidgetTextProps { | ||
text: string; | ||
} | ||
export const WidgetText: React.FC<WidgetTextProps> = ({ text }) => { | ||
return <span className="text-2xl font-semibold text-gray-900">{text}</span>; | ||
}; |
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.