From 8107a0e214023a5fa797bcba41aaa423c27cb141 Mon Sep 17 00:00:00 2001 From: bhenique Date: Sun, 8 Sep 2024 12:55:18 +0200 Subject: [PATCH] feat: add fathom script to become official, add theme to Drawer --- apps/web/src/routes/docs/index.tsx | 8 ++--- apps/web/src/routes/docs/layout.tsx | 12 +++++++ apps/web/src/routes/index.tsx | 36 +++++++++++++++++++ packages/lib/package.json | 2 +- packages/lib/src/components/Button/Button.tsx | 1 - .../Button/composables/use-button-classes.ts | 2 +- packages/lib/src/components/Drawer/Drawer.tsx | 18 +++++++--- .../Drawer/composables/use-drawer-classes.ts | 22 ++++++++---- 8 files changed, 82 insertions(+), 19 deletions(-) diff --git a/apps/web/src/routes/docs/index.tsx b/apps/web/src/routes/docs/index.tsx index 613bf3f36..83f75e49f 100644 --- a/apps/web/src/routes/docs/index.tsx +++ b/apps/web/src/routes/docs/index.tsx @@ -1,5 +1,5 @@ -import { component$ } from '@builder.io/qwik' +import { RequestHandler } from '@builder.io/qwik-city' -export default component$(() => { - return

Docs

-}) +export const onRequest: RequestHandler = (event) => { + throw event.redirect(301, '/docs/getting-started/introduction') +} diff --git a/apps/web/src/routes/docs/layout.tsx b/apps/web/src/routes/docs/layout.tsx index 1bff6d51e..8c34ac44c 100644 --- a/apps/web/src/routes/docs/layout.tsx +++ b/apps/web/src/routes/docs/layout.tsx @@ -131,6 +131,18 @@ window.gtag('config', 'G-78YXL53K0Y'); }, ] : []), + ...(import.meta.env.PROD + ? [ + { + props: { + defer: true, + type: 'text/partytown', + src: 'https://cdn.usefathom.com/script.js', + ['data-site']: 'ICKPULKH', + }, + }, + ] + : []), ], } } diff --git a/apps/web/src/routes/index.tsx b/apps/web/src/routes/index.tsx index b8d25b3a1..0752f115b 100644 --- a/apps/web/src/routes/index.tsx +++ b/apps/web/src/routes/index.tsx @@ -41,4 +41,40 @@ export default component$(() => { export const head = () => ({ title: 'Flowbite Qwik - UI Component Library', meta: [{ name: 'description', content: '⚡ Flowbite Qwik, component library based on Tailwind CSS' }], + scripts: [ + ...(import.meta.env.PROD + ? [ + { + props: { + async: true, + type: 'text/partytown', + src: 'https://www.googletagmanager.com/gtag/js?id=G-78YXL53K0Y', + }, + }, + { + props: { + type: 'text/partytown', + }, + script: ` +window.dataLayer = window.dataLayer || []; +window.gtag = function (){dataLayer.push(arguments);} +window.gtag('js', new Date()); +window.gtag('config', 'G-78YXL53K0Y'); +`, + }, + ] + : []), + ...(import.meta.env.PROD + ? [ + { + props: { + defer: true, + type: 'text/partytown', + src: 'https://cdn.usefathom.com/script.js', + ['data-site']: 'ICKPULKH', + }, + }, + ] + : []), + ], }) diff --git a/packages/lib/package.json b/packages/lib/package.json index e56797900..71c63ccb4 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,6 +1,6 @@ { "name": "flowbite-qwik", - "version": "0.36.2", + "version": "0.37.0", "description": "Unofficial Qwik components built for Flowbite and Tailwind CSS", "keywords": [ "design-system", diff --git a/packages/lib/src/components/Button/Button.tsx b/packages/lib/src/components/Button/Button.tsx index a537838ed..2fd497caa 100644 --- a/packages/lib/src/components/Button/Button.tsx +++ b/packages/lib/src/components/Button/Button.tsx @@ -85,7 +85,6 @@ export const Button = component$( target={href ? attrs.target : undefined} //@ts-expect-error does not exist on other elements disabled={!href && ButtonComponent === 'button' ? disabled : undefined} - onClick$={attrs.onClick$} {...attrs} > {!isOutlineGradient.value && (Prefix || loadingPrefix.value) && ( diff --git a/packages/lib/src/components/Button/composables/use-button-classes.ts b/packages/lib/src/components/Button/composables/use-button-classes.ts index 9d0d6c710..973a5a44f 100644 --- a/packages/lib/src/components/Button/composables/use-button-classes.ts +++ b/packages/lib/src/components/Button/composables/use-button-classes.ts @@ -260,7 +260,7 @@ export function useButtonClasses(props: UseButtonClassesProps) { (props.prefix || props.suffix || props.loading.value) && 'inline-flex items-center', clsx(props.class?.value), props.target?.value, - props.full.value && 'w-full', + props.full.value ? 'w-full' : 'w-fit', 'justify-center', ]) }) diff --git a/packages/lib/src/components/Drawer/Drawer.tsx b/packages/lib/src/components/Drawer/Drawer.tsx index 0ee76ea0e..2a67a9764 100644 --- a/packages/lib/src/components/Drawer/Drawer.tsx +++ b/packages/lib/src/components/Drawer/Drawer.tsx @@ -1,4 +1,4 @@ -import { Component, PropsOf, QRL, Signal, Slot, component$, useComputed$, useId, useSignal, useStyles$, useTask$ } from '@builder.io/qwik' +import { Component, PropsOf, QRL, Signal, Slot, component$, useComputed$, useId, useSignal, useStyles$, useTask$, ClassList } from '@builder.io/qwik' import clsx from 'clsx' import { twMerge } from 'tailwind-merge' import { useDrawerClasses } from './composables/use-drawer-classes' @@ -7,7 +7,12 @@ import type { IconProps } from 'flowbite-qwik-icons' import { IconCloseOutline } from 'flowbite-qwik-icons' import { isServer } from '@builder.io/qwik/build' -type DrawerProps = PropsOf<'div'> & { +export type DrawerTheme = { + header?: ClassList + leftRightWidth?: ClassList +} + +export type DrawerProps = PropsOf<'div'> & { 'bind:open': Signal title: string titleIcon?: Component @@ -15,21 +20,24 @@ type DrawerProps = PropsOf<'div'> & { backdrop?: boolean preventBodyScroll?: boolean onClose$?: QRL<() => void> + theme?: DrawerTheme } export const Drawer = component$( - ({ position = 'left', preventBodyScroll = true, backdrop = true, onClose$, class: classNames, title, titleIcon: TitleIcon, ...attrs }) => { + ({ position = 'left', preventBodyScroll = true, backdrop = true, onClose$, class: classNames, title, titleIcon: TitleIcon, theme, ...attrs }) => { const id = useId() const drawerRef = useSignal() const isEdge = useComputed$(() => position === 'bottom-edge') const internalPosition = useComputed$(() => position) const internalBackdrop = useComputed$(() => backdrop) + const internalTheme = useComputed$(() => theme) const { rootClasses, backdropClasses, headerClasses, closeButtonClasses, edgeHandleClasses } = useDrawerClasses( attrs['bind:open'], isEdge, internalPosition, + internalTheme, ) useStyles$(` @@ -66,7 +74,7 @@ export const Drawer = component$( aria-modal="true" role="dialog" ref={drawerRef} - class={twMerge(clsx(classNames), rootClasses.value)} + class={twMerge(rootClasses.value, clsx(classNames))} onKeyDown$={(e) => { if (e.key === 'Escape') { attrs['bind:open'].value = false @@ -95,7 +103,7 @@ export const Drawer = component$( }} class={closeButtonClasses} > - + Close menu )} diff --git a/packages/lib/src/components/Drawer/composables/use-drawer-classes.ts b/packages/lib/src/components/Drawer/composables/use-drawer-classes.ts index 1e92fe2cc..7baaabbf3 100644 --- a/packages/lib/src/components/Drawer/composables/use-drawer-classes.ts +++ b/packages/lib/src/components/Drawer/composables/use-drawer-classes.ts @@ -1,11 +1,18 @@ import { Signal, useComputed$ } from '@builder.io/qwik' import { DrawerPosition } from '../drawer-types' import { twMerge } from 'tailwind-merge' +import clsx from 'clsx' +import { DrawerTheme } from '~/components/Drawer/Drawer' -export function useDrawerClasses(isOpen: Signal, isEdge: Signal, position: Signal) { - const defaultClasses = 'fixed z-50 overflow-y-auto bg-white transition-transform dark:bg-gray-800' +export function useDrawerClasses( + isOpen: Signal, + isEdge: Signal, + position: Signal, + theme: Signal, +) { + const defaultClasses = 'fixed z-[60] overflow-y-auto bg-white transition-transform dark:bg-gray-800' const edgeClasses = 'rounded-t-lg border-t border-gray-200 rounded-t-lg dark:border-gray-700' - const backdropClasses = 'fixed inset-0 z-30 bg-gray-900/50 dark:bg-gray-900/80' + const backdropClasses = 'fixed inset-0 z-50 bg-gray-900/50 dark:bg-gray-900/80' const edgeHandleClasses = 'absolute w-8 h-1 -translate-x-1/2 bg-gray-300 rounded-lg top-3 left-1/2 dark:bg-gray-600' const closeButtonClasses = 'absolute end-2.5 top-2.5 flex h-8 w-8 items-center justify-center rounded-lg bg-transparent text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white' @@ -17,16 +24,16 @@ export function useDrawerClasses(isOpen: Signal, isEdge: Signal, isEdge: Signal