add button link for customized Link looking like a Button
This commit is contained in:
parent
9cb5b52ac9
commit
ee3ac34e4b
4 changed files with 34 additions and 28 deletions
|
|
@ -4,31 +4,38 @@ type ButtonProps = {
|
|||
onClick: () => void,
|
||||
icon?: Icon,
|
||||
text?: string,
|
||||
buttonType? : ButtonType
|
||||
buttonType?: ButtonType
|
||||
className?: string
|
||||
}
|
||||
|
||||
export const ButtonType = {
|
||||
DarkButton: {
|
||||
textColor: "dark-button-text",
|
||||
backgroundColor: "dark-button-bg"
|
||||
},
|
||||
PrimaryButton: {
|
||||
textColor: "primary-button-text",
|
||||
backgroundColor: "primary-button-bg"
|
||||
},
|
||||
DefaultButton: {
|
||||
textColor: "default-button-text",
|
||||
backgroundColor: "default-button-bg"
|
||||
}
|
||||
DarkButton: {
|
||||
textColor: "dark-button-text",
|
||||
backgroundColor: "dark-button-bg"
|
||||
},
|
||||
PrimaryButton: {
|
||||
textColor: "primary-button-text",
|
||||
backgroundColor: "primary-button-bg"
|
||||
},
|
||||
DefaultButton: {
|
||||
textColor: "default-button-text",
|
||||
backgroundColor: "default-button-bg"
|
||||
}
|
||||
} as const;
|
||||
|
||||
export type ButtonType = typeof ButtonType[keyof typeof ButtonType];
|
||||
|
||||
export default function Button ({onClick: onClick, icon, text, buttonType = ButtonType.DefaultButton} : ButtonProps){
|
||||
return(
|
||||
export default function Button(
|
||||
{
|
||||
onClick: onClick,
|
||||
icon, text,
|
||||
buttonType = ButtonType.DefaultButton,
|
||||
className = ""
|
||||
}: ButtonProps) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`basic-button ${buttonType.backgroundColor} ${buttonType.textColor}`}
|
||||
className={`basic-button ${buttonType.backgroundColor} ${buttonType.textColor} ${className}`}
|
||||
onClick={onClick}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
|
|
|
|||
0
frontend/src/components/basics/ButtonLink.tsx
Normal file
0
frontend/src/components/basics/ButtonLink.tsx
Normal file
|
|
@ -3,6 +3,7 @@ import type { Recipe } from "../../types/recipe"
|
|||
import { useEffect, useState } from "react"
|
||||
import { fetchRecipe } from "../../api/recipePoint"
|
||||
import { getRecipeEditUrl, getRecipeListUrl } from "../../routes"
|
||||
import ButtonLink from "../basics/ButtonLink"
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -123,18 +124,16 @@ export default function RecipeDetailPage() {
|
|||
|
||||
{/* Action buttons */}
|
||||
<div className="button-group">
|
||||
<Link
|
||||
to={ getRecipeEditUrl(recipe.id) }
|
||||
className="basic-button primary-button-bg primary-button-text"
|
||||
>
|
||||
Bearbeiten
|
||||
</Link>
|
||||
<Link
|
||||
<ButtonLink
|
||||
to={getRecipeEditUrl(recipe.id)}
|
||||
className="basic-button primary-button-bg primary-button-text"
|
||||
text="Bearbeiten"
|
||||
/>
|
||||
<ButtonLink
|
||||
to={getRecipeListUrl()}
|
||||
className="basic-button default-button-bg default-button-text"
|
||||
>
|
||||
Zurueck
|
||||
</Link>
|
||||
className="basic-button default-button-bg default-button-text"
|
||||
text="Zurueck"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export default function RecipeListToolbar({onSearchStringChanged, onAddClicked,
|
|||
</div>
|
||||
<Button
|
||||
buttonType = {ButtonType.PrimaryButton}
|
||||
//className="flex-shrink-0"
|
||||
className="flex-shrink-0"
|
||||
onClick={onAddClicked}
|
||||
text = "Add recipe"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue