diff --git a/src/components/balance/index.tsx b/src/components/balance/index.tsx index d826cbe2..662277be 100644 --- a/src/components/balance/index.tsx +++ b/src/components/balance/index.tsx @@ -1,11 +1,21 @@ import * as React from 'react'; -import styled from 'styled-components'; +import styled, { css } from 'styled-components'; import { ProgressBar } from '../generic/CardGeneric'; -const BalanceLine = styled.div` +type BalanceLineProps = { + withBorderColor?: boolean; +}; + +const BalanceLine = styled.div` width: 100%; display: flex; position: relative; + + ${({ withBorderColor }) => + withBorderColor && + css` + border: 1px solid gold; + `} `; const SingleLine = styled(BalanceLine)` @@ -35,6 +45,7 @@ type BalanceProps = { formatLocal?: string; formatRemote?: string; height?: number; + withBorderColor?: boolean; }; export const BalanceBars = ({ @@ -43,6 +54,7 @@ export const BalanceBars = ({ formatLocal, formatRemote, height = 20, + withBorderColor = false, }: BalanceProps) => { const localOpposite = 100 - local; const remoteOpposite = 100 - remote; @@ -59,7 +71,7 @@ export const BalanceBars = ({ formatRemote !== '0.00'; return ( - + {hasLocal && {formatLocal}} {hasRemote && {formatRemote}} diff --git a/src/components/generic/CardGeneric.tsx b/src/components/generic/CardGeneric.tsx index 3b5c7ff1..74497517 100644 --- a/src/components/generic/CardGeneric.tsx +++ b/src/components/generic/CardGeneric.tsx @@ -1,4 +1,5 @@ import styled, { css } from 'styled-components'; +import { ThemeSet } from 'styled-theming'; import { progressBackground, mediaWidths, @@ -18,31 +19,47 @@ interface ProgressBar { barHeight?: number; } -export const ProgressBar = styled.div` - height: ${({ barHeight }) => (barHeight ? `${barHeight}px` : '10px')}; - background-color: ${({ order }) => { +export const ProgressBar = styled.div.attrs( + ({ order, percent, barHeight }: ProgressBar) => { + let color: string | ThemeSet = chartColors.purple; switch (order) { case 1: - return chartColors.lightblue; + color = chartColors.lightblue; + break; case 2: - return chartColors.green; + color = chartColors.green; + break; case 3: - return chartColors.orange; + color = chartColors.orange; + break; case 4: - return progressBackground; + color = progressBackground; + break; case 5: - return chartColors.orange2; + color = chartColors.orange2; + break; case 6: - return chartColors.darkyellow; + color = chartColors.darkyellow; + break; case 7: - return chartColors.red; + color = chartColors.red; + break; case 8: - return 'transparent'; - default: - return chartColors.purple; + color = 'transparent'; + break; } - }}; - width: ${({ percent }) => `${percent}%`}; + + return { + backgroundColor: color, + barHeight: barHeight ? `${barHeight}px` : '10px', + style: { + width: `${percent}%`, + }, + }; + } +)` + background-color: ${({ backgroundColor }) => backgroundColor}; + height: ${({ barHeight }) => barHeight}; `; export const NodeTitle = styled.div` diff --git a/src/context/ConfigContext.tsx b/src/context/ConfigContext.tsx index 3f691069..05569023 100644 --- a/src/context/ConfigContext.tsx +++ b/src/context/ConfigContext.tsx @@ -23,6 +23,7 @@ export type channelSortTypes = | 'size'; export type sortDirectionTypes = 'increase' | 'decrease'; export type subBarType = 'fees' | 'none'; +export type maxSatValueType = 'auto' | 1000000 | 5000000 | 10000000 | 16000000; type State = { currency: string; @@ -40,6 +41,7 @@ type State = { channelSort: channelSortTypes; sortDirection: sortDirectionTypes; subBar: subBarType; + maxSatValue: maxSatValueType; }; type ConfigInitProps = { @@ -64,6 +66,7 @@ type ActionType = channelSort?: channelSortTypes; sortDirection?: sortDirectionTypes; subBar?: subBarType; + maxSatValue?: maxSatValueType; } | { type: 'themeChange'; theme: string }; @@ -96,6 +99,7 @@ const initialState: State = { channelSort: 'none', sortDirection: 'decrease', subBar: 'none', + maxSatValue: 'auto', }; const stateReducer = (state: State, action: ActionType): State => { diff --git a/src/views/channels/channels/Channel.style.ts b/src/views/channels/channels/Channel.style.ts index 4c910a29..43c947a0 100644 --- a/src/views/channels/channels/Channel.style.ts +++ b/src/views/channels/channels/Channel.style.ts @@ -96,7 +96,7 @@ export const ChannelBalanceButton = styled.button` background-color: ${({ selected }) => selected ? chartColors.orange : colorButtonBackground}; - @media(${mediaWidths.mobile}) { + @media (${mediaWidths.mobile}) { margin: 8px 8px 16px; width: 100%; } @@ -115,3 +115,11 @@ export const ChannelGoToToast = styled.div` width: 100%; text-align: center; `; + +export const WumboTag = styled.div` + width: 100%; + border-radius: 4px; + border: 1px solid gold; + text-align: center; + padding: 2px 0; +`; diff --git a/src/views/channels/channels/ChannelCard.tsx b/src/views/channels/channels/ChannelCard.tsx index e98912df..2d7f71e6 100644 --- a/src/views/channels/channels/ChannelCard.tsx +++ b/src/views/channels/channels/ChannelCard.tsx @@ -56,7 +56,9 @@ import { ChannelStatsLine, ChannelBalanceRow, ChannelBalanceButton, + WumboTag, } from './Channel.style'; +import { WUMBO_MIN_SIZE } from './Channels'; const getSymbol = (status: boolean) => { return status ? : ; @@ -219,9 +221,23 @@ export const ChannelCard: React.FC = ({ Partner node not found ); + const renderWumboInfo = () => { + if (local_balance + remote_balance >= WUMBO_MIN_SIZE) { + return ( + <> + + This channel is Wumbo! + + ); + } + + return null; + }; + const renderDetails = () => { return ( <> + {renderWumboInfo()} {renderLine('Status:', is_active ? 'Active' : 'Not Active')} {renderLine('Is Opening:', is_opening ? 'True' : 'False')} @@ -343,6 +359,7 @@ export const ChannelCard: React.FC = ({ remote={getBar(remote_balance, biggest)} formatLocal={localBalance} formatRemote={remoteBalance} + withBorderColor={local_balance + remote_balance >= WUMBO_MIN_SIZE} /> ); diff --git a/src/views/channels/channels/ChannelManage.tsx b/src/views/channels/channels/ChannelManage.tsx index eabca237..4485af9e 100644 --- a/src/views/channels/channels/ChannelManage.tsx +++ b/src/views/channels/channels/ChannelManage.tsx @@ -11,6 +11,7 @@ import { channelSortTypes, sortDirectionTypes, subBarType, + maxSatValueType, } from 'src/context/ConfigContext'; import { Card, @@ -37,6 +38,7 @@ export const ChannelManage = () => { channelSort, sortDirection, subBar, + maxSatValue, } = useConfigState(); const dispatch = useConfigDispatch(); @@ -50,6 +52,8 @@ export const ChannelManage = () => { dispatch({ type: 'change', channelSort: type }); const changeDirection = (type: sortDirectionTypes) => dispatch({ type: 'change', sortDirection: type }); + const changeMaxValue = (type: maxSatValueType) => + dispatch({ type: 'change', maxSatValue: type }); const renderOpenButton = () => ( @@ -162,6 +166,43 @@ export const ChannelManage = () => { + {channelBarType === 'proportional' && ( + + Max Sat Value + + changeMaxValue(16000000)} + > + Wumbo (16m) + + changeMaxValue(10000000)} + > + 10m + + changeMaxValue(5000000)} + > + 5m + + changeMaxValue(1000000)} + > + 1m + + changeMaxValue('auto')} + > + Auto + + + + )} {(channelBarType === 'proportional' || channelBarType === 'balance') && ( @@ -260,181 +301,4 @@ export const ChannelManage = () => { }; return {renderContent()}; - - return ( - <> - - - Open Channel - setOpenWindow('none')} - > - {openWindow === 'open' ? : 'Open'} - - - {openWindow === 'open' ? ( - <> - - setOpenWindow('none')} /> - - ) : ( - <> - - - - Card Type - - changeStyle('normal')} - > - Normal - - changeStyle('compact')} - > - Compact - - changeStyle('ultracompact')} - > - Ultra-Compact - - changeStyle('balancing')} - > - Balancing - - - - - Bar Types - - changeType('balance')} - > - Balance - - changeType('proportional')} - > - Proportional - - changeType('size')} - > - Partner Size - - changeType('fees')} - > - Fees - - - - {(channelBarType === 'proportional' || - channelBarType === 'balance') && ( - - Sub Bar - - changeSub('fees')} - > - Fee Rate - - changeSub('none')} - > - None - - - - )} - - Sort - - changeSort('none')} - > - None - - changeSort('age')} - > - Age - - changeSort('local')} - > - Local - - changeSort('balance')} - > - Balance - - changeSort('deviation')} - > - Deviation - - changeSort('feeRate')} - > - Fee Rate - - changeSort('partnerName')} - > - Name - - changeSort('size')} - > - Size - - - - {channelSort !== 'none' && ( - - Direction - - changeDirection('increase')} - > - Increasing - - changeDirection('decrease')} - > - Decreasing - - - - )} - - )} - - - ); }; diff --git a/src/views/channels/channels/Channels.tsx b/src/views/channels/channels/Channels.tsx index 2bcd97fd..7ad10420 100644 --- a/src/views/channels/channels/Channels.tsx +++ b/src/views/channels/channels/Channels.tsx @@ -14,11 +14,13 @@ import { LoadingCard } from '../../../components/loading/LoadingCard'; import { ChannelCard } from './ChannelCard'; import { ChannelGoToToast } from './Channel.style'; +export const WUMBO_MIN_SIZE = 16000000; + export const Channels: React.FC = () => { const toastId = useRef(null); const { push } = useRouter(); - const { sortDirection, channelSort } = useConfigState(); + const { sortDirection, channelSort, maxSatValue } = useConfigState(); const [indexOpen, setIndexOpen] = useState(0); const { inChannel, outChannel } = useRebalanceState(); @@ -79,7 +81,11 @@ export const Channels: React.FC = () => { const partner = Number(capacity) || 0; const channels = Number(channel_count) || 0; - const max = Math.max(local_balance || 0, remote_balance || 0); + let max = Math.max(local_balance || 0, remote_balance || 0); + + if (maxSatValue !== 'auto') { + max = Math.min(max, maxSatValue); + } if (max > biggest) { biggest = max;