|
| 1 | +/** |
| 2 | + * Material Design 3 App Bar Component - Tailwind Plugin |
| 3 | + */ |
| 4 | + |
| 5 | +import plugin from 'tailwindcss/plugin'; |
| 6 | + |
| 7 | +export const appBarPlugin: ReturnType<typeof plugin> = plugin(function ({ addComponents }) { |
| 8 | + const appBars = { |
| 9 | + // Top App Bar Container |
| 10 | + '.md-top-app-bar': { |
| 11 | + '@apply sticky top-0 left-0 right-0 z-40 flex items-center gap-4 px-4 h-16 bg-md-surface': {}, |
| 12 | + '@apply transition-all duration-200': {}, |
| 13 | + |
| 14 | + // Scrolled state (optional, adds elevation/color change) |
| 15 | + '&.scrolled': { |
| 16 | + '@apply bg-md-surface-container shadow-md-2': {}, |
| 17 | + }, |
| 18 | + |
| 19 | + // Small App Bar |
| 20 | + '&.md-top-app-bar-small': { |
| 21 | + '@apply h-16': {}, |
| 22 | + }, |
| 23 | + // Medium App Bar (expands) |
| 24 | + '&.md-top-app-bar-medium': { |
| 25 | + '@apply h-[112px] flex-col items-start justify-end pb-6': {}, |
| 26 | + '.md-top-app-bar-title': { |
| 27 | + '@apply text-md-headline-small': {}, |
| 28 | + } |
| 29 | + }, |
| 30 | + // Large App Bar |
| 31 | + '&.md-top-app-bar-large': { |
| 32 | + '@apply h-[152px] flex-col items-start justify-end pb-7': {}, |
| 33 | + '.md-top-app-bar-title': { |
| 34 | + '@apply text-md-headline-medium': {}, |
| 35 | + } |
| 36 | + }, |
| 37 | + |
| 38 | + // Leading Icon (Menu/Back) |
| 39 | + '.md-top-app-bar-leading': { |
| 40 | + '@apply p-3 -ml-3 rounded-md-full text-md-on-surface hover:bg-md-on-surface/10 cursor-pointer': {}, |
| 41 | + }, |
| 42 | + |
| 43 | + // Title |
| 44 | + '.md-top-app-bar-title': { |
| 45 | + '@apply flex-1 text-md-title-large text-md-on-surface truncate': {}, |
| 46 | + }, |
| 47 | + |
| 48 | + // Trailing Actions Container |
| 49 | + '.md-top-app-bar-actions': { |
| 50 | + '@apply flex items-center gap-2 -mr-2': {}, |
| 51 | + }, |
| 52 | + |
| 53 | + // Action Icon |
| 54 | + '.md-top-app-bar-action': { |
| 55 | + '@apply p-3 rounded-md-full text-md-on-surface-variant hover:bg-md-on-surface/10 cursor-pointer': {}, |
| 56 | + } |
| 57 | + }, |
| 58 | + |
| 59 | + // Bottom App Bar |
| 60 | + '.md-bottom-app-bar': { |
| 61 | + '@apply fixed bottom-0 left-0 right-0 z-40 flex items-center justify-between gap-4 px-4 h-20 bg-md-surface-container': {}, |
| 62 | + // FAB usually lives here or floats above |
| 63 | + '.md-fab': { |
| 64 | + '@apply absolute right-4 bottom-4 shadow-md-3': {}, // Or inline if wanted |
| 65 | + } |
| 66 | + } |
| 67 | + }; |
| 68 | + |
| 69 | + addComponents(appBars); |
| 70 | +}); |
| 71 | + |
| 72 | +export default appBarPlugin; |
0 commit comments