-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
styling(tile): add icons to tile card
- Loading branch information
1 parent
e4b002e
commit abced6d
Showing
6 changed files
with
176 additions
and
28 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
next-tavla/app/(admin)/components/CreateBoard/StopPlaceList.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,25 @@ | ||
import { Paragraph } from '@entur/typography' | ||
import { TTile } from 'types/tile' | ||
import { TileCard } from './TileCard' | ||
|
||
function StopPlaceList({ | ||
tiles, | ||
onRemove, | ||
}: { | ||
tiles?: TTile[] | ||
onRemove: (tile: TTile) => void | ||
}) { | ||
if (!tiles || tiles.length === 0) | ||
return ( | ||
<Paragraph>Du har ikke lagt til noen stoppesteder enda.</Paragraph> | ||
) | ||
return ( | ||
<div className="g-2 m-2"> | ||
{tiles.map((tile) => ( | ||
<TileCard key={tile.uuid} tile={tile} onRemove={onRemove} /> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export { StopPlaceList } |
52 changes: 52 additions & 0 deletions
52
next-tavla/app/(admin)/components/CreateBoard/TileCard.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,52 @@ | ||
'use client' | ||
import { IconButton } from '@entur/button' | ||
import { DeleteIcon } from '@entur/icons' | ||
import { useLines } from 'app/(admin)/edit/[id]/components/TileCard/useLines' | ||
import { TransportIcon } from 'components/TransportIcon' | ||
import classes from './styles.module.css' | ||
import { TTile } from 'types/tile' | ||
import { uniqBy } from 'lodash' | ||
|
||
function TileCard({ | ||
tile, | ||
onRemove, | ||
}: { | ||
tile: TTile | ||
onRemove: (tile: TTile) => void | ||
}) { | ||
console.log('tile', tile) | ||
const lines = useLines(tile) | ||
if (!lines) return <div className={classes.card}>Laster..</div> | ||
console.log('lines', lines) | ||
const transportModes = uniqBy(lines, 'transportMode') | ||
.map((l) => l.transportMode) | ||
.sort() | ||
console.log('transportModes', transportModes) | ||
|
||
return ( | ||
<div> | ||
<div className={classes.card}> | ||
<div className="flexRow g-2 alignCenter"> | ||
<div className="flexRow g-2 h-3"> | ||
{transportModes.map((tm) => ( | ||
<TransportIcon transportMode={tm} key={tm} /> | ||
))} | ||
</div> | ||
{tile.name} | ||
</div> | ||
<div className="flexRow"> | ||
<IconButton | ||
onClick={() => { | ||
onRemove | ||
}} | ||
> | ||
<DeleteIcon /> | ||
Fjern | ||
</IconButton> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export { TileCard } |
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,18 +1,32 @@ | ||
'use server' | ||
|
||
import { getUserFromSessionCookie } from 'Admin/utils/formActions' | ||
import { TFormFeedback, getFormFeedbackForError } from 'app/(admin)/utils' | ||
import { revalidatePath } from 'next/cache' | ||
import { initializeAdminApp } from 'Admin/utils/firebase' | ||
import admin, { firestore } from 'firebase-admin' | ||
import { TBoard, TOrganizationID, TUserID } from 'types/settings' | ||
|
||
initializeAdminApp() | ||
|
||
export async function createBoard( | ||
prevState: TFormFeedback | undefined, | ||
data: FormData, | ||
id: TUserID | TOrganizationID, | ||
board: TBoard, | ||
collection: 'users' | 'organizations', | ||
) { | ||
const user = await getUserFromSessionCookie() | ||
|
||
if (!user) return getFormFeedbackForError('general') | ||
|
||
console.log(data) | ||
|
||
revalidatePath('/') | ||
const createdBoard = await firestore() | ||
.collection('boards') | ||
.add({ | ||
...board, | ||
meta: { | ||
...board.meta, | ||
created: Date.now(), | ||
dateModified: Date.now(), | ||
}, | ||
}) | ||
firestore() | ||
.collection(collection) | ||
.doc(id) | ||
.update({ | ||
[collection === 'users' ? 'owner' : 'boards']: | ||
admin.firestore.FieldValue.arrayUnion(createdBoard.id), | ||
}) | ||
return createdBoard.id | ||
} |
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
15 changes: 15 additions & 0 deletions
15
next-tavla/app/(admin)/components/CreateBoard/styles.module.css
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,15 @@ | ||
.card { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
border-radius: 0.5em; | ||
border: 1px solid var(--colors-brand-blue); | ||
margin-bottom: 1em; | ||
padding: 0.5em; | ||
} | ||
|
||
.publicCode { | ||
background-color: var(--tertiary-background-color); | ||
padding: 0.35em 0.5em; | ||
border-radius: 0.5em; | ||
} |
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