Skip to content

Commit

Permalink
Merge pull request #2263 from stakwork/feature/add-stak-messages
Browse files Browse the repository at this point in the history
feat: remove messages bar, when there is not messages
  • Loading branch information
Rassl authored Sep 30, 2024
2 parents 61c04df + 3f99f8a commit 00bbdc4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions src/components/Stats/Alerts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import { useDataStore } from '~/stores/useDataStore'
import { colors } from '~/utils'

export const Alerts = () => {
console.log(12)

const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
const [listOfItems] = useState<string[]>([])
const { runningProjectMessages } = useDataStore((s) => s)

const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
Expand All @@ -25,7 +22,7 @@ export const Alerts = () => {
const open = Boolean(anchorEl)
const id = open ? 'simple-popover' : undefined

return (
return runningProjectMessages.length ? (
<AlertWrapper ml={8}>
<Info onClick={handleClick}>
<Tooltip content="Messages" margin="18px">
Expand All @@ -47,14 +44,16 @@ export const Alerts = () => {
onClose={handleClose}
open={open}
>
<Flex p={16}>
{[...listOfItems, ...runningProjectMessages].map((i) => (
<p key={i}>{i}</p>
<ContentWrapper p={16}>
{runningProjectMessages.map((i) => (
<p key={i} className="item">
{i}
</p>
))}
</Flex>
</ContentWrapper>
</Popover>
</AlertWrapper>
)
) : null
}

const AlertWrapper = styled(Flex).attrs({
Expand All @@ -64,11 +63,28 @@ const AlertWrapper = styled(Flex).attrs({
justify: 'flex-start',
})``

const ContentWrapper = styled(Flex)`
max-height: 33vh;
max-width: 30vw;
.item {
background: ${colors.BG1};
padding: 4px 0;
border-bottom: 1px solid ${colors.black};
word-break: break-word;
}
.item:last-child {
border: none;
}
`

const Info = styled(Flex).attrs({
align: 'center',
direction: 'row',
})`
display: flex;
cursor: pointer;
height: 2.5rem;
padding: 0.75rem 0.9375rem 0.75rem 0.9375rem;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export const useDataStore = create<DataStore>()(
console.log(id)

Check warning on line 350 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
},

setRunningProjectId: (runningProjectId) => set({ runningProjectId }),
setRunningProjectId: (runningProjectId) => set({ runningProjectId, runningProjectMessages: [] }),
setRunningProjectMessages: (message) => {
const { runningProjectMessages } = get()

Expand Down

0 comments on commit 00bbdc4

Please sign in to comment.