Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deletetile): modal for deleting a tile #1108

Merged
merged 6 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions next-tavla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@entur/icons": "6.3.0",
"@entur/layout": "2.1.33",
"@entur/loader": "0.4.31",
"@entur/modal": "1.7.3",
"@entur/tokens": "3.8.1",
"@entur/typography": "1.8.0",
"@firebase/database-types": "0.10.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useState } from 'react'
import { ButtonGroup, SecondaryButton } from '@entur/button'
import { Modal } from '@entur/modal'
import { Paragraph } from '@entur/typography'
import { PrimaryButton, TertiaryButton } from '@entur/button'
import { DeleteIcon } from '@entur/icons'
import { useSettingsDispatch } from 'Admin/utils/contexts'

function DeleteButton({ uuid }: { uuid: string }) {
const dispatch = useSettingsDispatch()
const [isOpen, setOpen] = useState(false)

return (
<>
<Modal
open={isOpen}
onDismiss={() => setOpen(false)}
size="small"
align="center"
>
<Paragraph>
Er du sikker på at du vil slette denne holdeplassen?
</Paragraph>
<ButtonGroup>
<SecondaryButton onClick={() => setOpen(false)}>
Avbryt
</SecondaryButton>
<PrimaryButton
onClick={() => {
setOpen(false)
dispatch({
type: 'removeTile',
tileId: uuid,
})
}}
>
Ja, slett
</PrimaryButton>
</ButtonGroup>
</Modal>

<TertiaryButton onClick={() => setOpen(true)}>
<DeleteIcon />
{'Slett'}
</TertiaryButton>
</>
)
}

export { DeleteButton }
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import classes from './styles.module.css'
import { useSettingsDispatch } from 'Admin/utils/contexts'
import { DeleteIcon } from '@entur/icons'
import { Loader } from '@entur/loader'
import { Tile } from 'components/Tile'
import { TavlaButton } from 'Admin/components/Button'
import { DeleteButton } from '../DeleteButton'

function TileSettingsWrapper({
uuid,
Expand All @@ -15,25 +13,14 @@ function TileSettingsWrapper({
name: string | undefined
children: React.ReactNode
}) {
const dispatch = useSettingsDispatch()

return (
<Tile>
<div className={classes.heading}>
{!name ? <Loader /> : name}
<div className={classes.buttons}>
<TavlaButton
onClick={() =>
dispatch({
type: 'removeTile',
tileId: uuid,
})
}
>
<DeleteIcon size={16} />
</TavlaButton>
</div>

<DeleteButton uuid={uuid} />
</div>

{children}
</Tile>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 0.5em;
}

.buttons {
display: flex;
flex: 0;
padding-bottom: 1em;
}
1 change: 1 addition & 0 deletions next-tavla/src/Shared/styles/imports.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
@import '@entur/expand/dist/styles.css';
@import '@entur/tokens/dist/styles.css';
@import '@entur/alert/dist/styles.css';
@import '@entur/modal/dist/styles.css';
Loading