-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EditDialog: show CharacterCount only for >= 150 chars
- Loading branch information
Showing
2 changed files
with
35 additions
and
31 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
29 changes: 29 additions & 0 deletions
29
src/components/FeaturePanel/EditDialog/EditContent/helpers.tsx
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,29 @@ | ||
import styled from '@emotion/styled'; | ||
import { Box, Stack } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
const CharacterCountContainer = styled.div` | ||
position: absolute; | ||
right: 0; | ||
`; | ||
|
||
type CharacterCountProps = { | ||
count?: number; | ||
max: number; | ||
isInputFocused: boolean; | ||
}; | ||
|
||
export const CharacterCount = ({ | ||
count = 0, | ||
max, | ||
isInputFocused, | ||
}: CharacterCountProps) => | ||
isInputFocused && count > 150 ? ( | ||
<CharacterCountContainer> | ||
<Stack direction="row" justifyContent={'flex-end'} whiteSpace="nowrap"> | ||
<Box color={count >= max ? 'error.main' : undefined}> | ||
{count} / {max} | ||
</Box> | ||
</Stack> | ||
</CharacterCountContainer> | ||
) : null; |