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,
|
onClick: () => void,
|
||||||
icon?: Icon,
|
icon?: Icon,
|
||||||
text?: string,
|
text?: string,
|
||||||
buttonType? : ButtonType
|
buttonType?: ButtonType
|
||||||
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ButtonType = {
|
export const ButtonType = {
|
||||||
DarkButton: {
|
DarkButton: {
|
||||||
textColor: "dark-button-text",
|
textColor: "dark-button-text",
|
||||||
backgroundColor: "dark-button-bg"
|
backgroundColor: "dark-button-bg"
|
||||||
},
|
},
|
||||||
PrimaryButton: {
|
PrimaryButton: {
|
||||||
textColor: "primary-button-text",
|
textColor: "primary-button-text",
|
||||||
backgroundColor: "primary-button-bg"
|
backgroundColor: "primary-button-bg"
|
||||||
},
|
},
|
||||||
DefaultButton: {
|
DefaultButton: {
|
||||||
textColor: "default-button-text",
|
textColor: "default-button-text",
|
||||||
backgroundColor: "default-button-bg"
|
backgroundColor: "default-button-bg"
|
||||||
}
|
}
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type ButtonType = typeof ButtonType[keyof typeof ButtonType];
|
export type ButtonType = typeof ButtonType[keyof typeof ButtonType];
|
||||||
|
|
||||||
export default function Button ({onClick: onClick, icon, text, buttonType = ButtonType.DefaultButton} : ButtonProps){
|
export default function Button(
|
||||||
return(
|
{
|
||||||
|
onClick: onClick,
|
||||||
|
icon, text,
|
||||||
|
buttonType = ButtonType.DefaultButton,
|
||||||
|
className = ""
|
||||||
|
}: ButtonProps) {
|
||||||
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`basic-button ${buttonType.backgroundColor} ${buttonType.textColor}`}
|
className={`basic-button ${buttonType.backgroundColor} ${buttonType.textColor} ${className}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<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 { useEffect, useState } from "react"
|
||||||
import { fetchRecipe } from "../../api/recipePoint"
|
import { fetchRecipe } from "../../api/recipePoint"
|
||||||
import { getRecipeEditUrl, getRecipeListUrl } from "../../routes"
|
import { getRecipeEditUrl, getRecipeListUrl } from "../../routes"
|
||||||
|
import ButtonLink from "../basics/ButtonLink"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,18 +124,16 @@ export default function RecipeDetailPage() {
|
||||||
|
|
||||||
{/* Action buttons */}
|
{/* Action buttons */}
|
||||||
<div className="button-group">
|
<div className="button-group">
|
||||||
<Link
|
<ButtonLink
|
||||||
to={ getRecipeEditUrl(recipe.id) }
|
to={getRecipeEditUrl(recipe.id)}
|
||||||
className="basic-button primary-button-bg primary-button-text"
|
className="basic-button primary-button-bg primary-button-text"
|
||||||
>
|
text="Bearbeiten"
|
||||||
Bearbeiten
|
/>
|
||||||
</Link>
|
<ButtonLink
|
||||||
<Link
|
|
||||||
to={getRecipeListUrl()}
|
to={getRecipeListUrl()}
|
||||||
className="basic-button default-button-bg default-button-text"
|
className="basic-button default-button-bg default-button-text"
|
||||||
>
|
text="Zurueck"
|
||||||
Zurueck
|
/>
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export default function RecipeListToolbar({onSearchStringChanged, onAddClicked,
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
buttonType = {ButtonType.PrimaryButton}
|
buttonType = {ButtonType.PrimaryButton}
|
||||||
//className="flex-shrink-0"
|
className="flex-shrink-0"
|
||||||
onClick={onAddClicked}
|
onClick={onAddClicked}
|
||||||
text = "Add recipe"
|
text = "Add recipe"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue