Skip to content

Commit

Permalink
💄(buttons) style buttons like in the figma
Browse files Browse the repository at this point in the history
add new variant option to button component to be able to easily
create the outline buttons
  • Loading branch information
manuhabitela authored and lebaudantoine committed Apr 2, 2024
1 parent f747e23 commit fd66c5c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
36 changes: 21 additions & 15 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CommonProps } from '@/types'
interface ButtonProps extends CommonProps {
href?: string
'aria-label'?: string
variant?: 'outline'
}

export const ButtonStyle =
Expand All @@ -14,19 +15,24 @@ export const Button: React.FC<ButtonProps> = ({
children,
href,
className,
variant,
'aria-label': ariaLabel,
}) => (
<>
{href ? (
<Link
href={href}
className={twMerge(ButtonStyle, className)}
aria-label={ariaLabel}
>
{children}
</Link>
) : (
<button className={twMerge(ButtonStyle, className)}>{children}</button>
)}
</>
)
}) => {
const classNames = twMerge(
ButtonStyle,
variant === 'outline' &&
'bg-transparent border border-2 font-bold border-blue-1 text-blue-1 hover:bg-dsfr-hover-tint',
className
)
return (
<>
{href ? (
<Link href={href} className={classNames} aria-label={ariaLabel}>
{children}
</Link>
) : (
<button className={classNames}>{children}</button>
)}
</>
)
}
9 changes: 6 additions & 3 deletions src/pages/communs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Image from 'next/image'
import { ButtonExternalLink } from '@/components/ExternalLink'
import { Button } from '@/components/Button'
import { Br } from '@/components/Br'
import { Layout } from '@/components/Layout'

Expand Down Expand Up @@ -222,9 +222,12 @@ export default function Communs() {
</div>
<h2 className="sr-only">Proposer un projet</h2>
<p className="w-full justify-center flex pt-10 pb-40">
<ButtonExternalLink href="https://www.demarches-simplifiees.fr/commencer/fonds-communs-numeriques-pour-la-suite-numerique">
<Button
variant="outline"
href="https://www.demarches-simplifiees.fr/commencer/fonds-communs-numeriques-pour-la-suite-numerique"
>
Je propose mon projet&nbsp;!
</ButtonExternalLink>
</Button>
</p>
</Layout>
)
Expand Down
7 changes: 2 additions & 5 deletions src/sections/Initiatives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ export const Initiatives = () => (
du fonds communs numériques pour La Suite collaborative.
</p>
<p>
<Button
aria-label="En savoir plus sur comment contribuer à La Suite numérique"
href="/communs"
>
En savoir plus
<Button href="/communs" variant="outline" className="hover:bg-white">
Comment proposer mon projet ?
</Button>
</p>
</ContentSection>
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const config: Config = {
'blue-1': '#f5f5fe',
'blue-2': '#1212ff',
'blue-3': '#f3f6fe',
'hover-tint': '#f6f6f6',
},
},
extend: {
Expand Down

0 comments on commit fd66c5c

Please sign in to comment.