-
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.
- Loading branch information
1 parent
ae2c82b
commit 4578d69
Showing
25 changed files
with
309 additions
and
762 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
interface DataPairProps { | ||
children: React.ReactNode; | ||
last?: boolean; | ||
} | ||
|
||
export const DataPair: React.FC<DataPairProps> = ({ children, last }) => { | ||
return ( | ||
<div | ||
className={classNames( | ||
last ? 'border-0' : 'border-r', | ||
'flex h-full min-w-[12rem] max-w-[18rem] flex-col gap-2 px-2 md:min-w-[12rem]' | ||
)} | ||
> | ||
{children} | ||
</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,44 @@ | ||
import React from 'react'; | ||
import type { WidgetValueInterface } from '../../types/basicWidgets'; | ||
import { DataPair } from '../general/DataPair'; | ||
import { SmallDelta } from './internal/SmallDelta'; | ||
import { SmallData } from './internal/SmallData'; | ||
|
||
interface MiniWidgetObject { | ||
type: 'delta' | 'data' | string; | ||
widgetValue: WidgetValueInterface; | ||
text: string; | ||
} | ||
[]; | ||
|
||
interface MiniWidgetCreatorProps { | ||
widgetObjects: MiniWidgetObject[]; | ||
} | ||
|
||
const getDeltaOrDataComponent = (widgetObject: MiniWidgetObject) => { | ||
if (widgetObject.type === 'delta') { | ||
return <SmallDelta analysis={widgetObject.text} widgetValue={widgetObject.widgetValue} />; | ||
} | ||
return <SmallData analysis={widgetObject.text} widgetValue={widgetObject.widgetValue} />; | ||
}; | ||
|
||
const getWidgets = (widgetObject: MiniWidgetObject[]) => { | ||
const widgets: React.ReactNode[] = []; | ||
for (let x = 0; x < widgetObject.length; x += 2) { | ||
widgets.push( | ||
<DataPair last={x + 3 > widgetObject.length}> | ||
{getDeltaOrDataComponent(widgetObject[x])} | ||
{x + 1 < widgetObject.length ? getDeltaOrDataComponent(widgetObject[x + 1]) : null} | ||
</DataPair> | ||
); | ||
} | ||
return widgets; | ||
}; | ||
|
||
export const MiniWidgetCreator: React.FC<MiniWidgetCreatorProps> = ({ widgetObjects }) => { | ||
return ( | ||
<div className="flex w-full flex-row gap-y-4 overflow-x-auto py-2"> | ||
{getWidgets(widgetObjects)} | ||
</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,21 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import type { WidgetValueInterface } from '../../../types/basicWidgets'; | ||
|
||
type SmallDataProps = { | ||
analysis: React.ReactNode; | ||
widgetValue: WidgetValueInterface; | ||
}; | ||
|
||
export const SmallData: React.FC<SmallDataProps> = ({ analysis, widgetValue }) => { | ||
return ( | ||
<div className=" flex flex-row items-end justify-between"> | ||
<p | ||
className={classNames('truncate text-xs leading-tight text-design-subtitleGrey sm:text-sm')} | ||
> | ||
{analysis} | ||
</p> | ||
<div className="flex flex-row items-baseline gap-x-1">{widgetValue.getFormattedValue()}</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,38 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faArrowTrendDown, faArrowTrendUp } from '@fortawesome/free-solid-svg-icons'; | ||
import type { WidgetValueInterface } from '../../../types/basicWidgets'; | ||
|
||
type SmallDeltaProps = { | ||
analysis: React.ReactNode; | ||
widgetValue: WidgetValueInterface; | ||
}; | ||
|
||
export const SmallDelta: React.FC<SmallDeltaProps> = ({ analysis, widgetValue }) => { | ||
return ( | ||
<div className=" flex flex-row items-end justify-between"> | ||
<p | ||
className={classNames('truncate text-xs leading-tight text-design-subtitleGrey sm:text-sm')} | ||
> | ||
{analysis} | ||
</p> | ||
{widgetValue.value !== undefined && ( | ||
<div className={classNames('flex flex-row items-center gap-1 rounded-md px-2')}> | ||
{widgetValue.value !== 0 && ( | ||
<FontAwesomeIcon | ||
icon={widgetValue.value > 0 ? faArrowTrendUp : faArrowTrendDown} | ||
className={widgetValue.value > 0 ? 'text-[#e84e3b]' : 'text-[#35c759]'} | ||
/> | ||
)} | ||
<p className="flex flex-row"> | ||
<span className="pr-1 font-bold text-gray-900"> | ||
{widgetValue.value < 0 ? '-' : '+'} | ||
</span> | ||
{widgetValue.getFormattedValue(false)} | ||
</p> | ||
</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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
export interface UnitTextProps { | ||
text: string; | ||
light?: boolean; | ||
} | ||
export const UnitText: React.FC<UnitTextProps> = ({ text }) => { | ||
return <span className="text-base text-design-subtitleGrey">{text}</span>; | ||
export const UnitText: React.FC<UnitTextProps> = ({ text, light }) => { | ||
return ( | ||
<span className={classNames(light ? 'text-stone-200' : 'text-stone-700', 'text-base ')}> | ||
{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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
export interface WidgetTextProps { | ||
text: string; | ||
light?: boolean; | ||
} | ||
export const WidgetText: React.FC<WidgetTextProps> = ({ text }) => { | ||
return <span className="text-2xl font-semibold text-gray-900">{text}</span>; | ||
export const WidgetText: React.FC<WidgetTextProps> = ({ text, light }) => { | ||
return ( | ||
<span | ||
className={classNames(light ? 'text-stone-100' : 'text-stone-900', 'text-base font-semibold')} | ||
> | ||
{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 was deleted.
Oops, something went wrong.
Oops, something went wrong.