An extension of `astro-pwa-starter` defining simple common component types and a json based way of managing/separating Tailwind definitions. Aims to provide the lego pieces needed to service most needs of most simple websites with AstroJS + Tailwind3, while defining base components extensibly enough to simplify building webapps/web3 dApps of any complexity.
Core components are made, but where shared state between components is required (like nav), it hasn't been handled yet. Layout also needs work... should return to a single layout but was speedrunning and lazy. Both are included in a planned refactor/code cleanup phase.
More detail about the starter this is based off can be found at shawunchander/astro-pwa-starter, or at it's README which is included here . This README will for now focus mostly on the set of components rolled atop that starter repo.
main.astro
: the OGastro-pwa-starter
mostly unblemishedindex.astro
: a landing page not connected to the components (Affordable Audience is a potential project that will require a lot of canned/re-useable components to run with, which is what begat this project)agency.astro
: the screenshot visible below. its not pretty... at all. but it is increasingly lego-like and could almost service most simple static website needs.
Container
: generic div style container, used by nearly everythingContainerFull
: a simple extension enforcing full widthContainerCentered
: a simple extension defining a centered box (super gross impl atm, @todo: fix)ContainerJustified
: a simple extension defining a justified divSplit
: a container comprised of 2 child containers with slot names "left" and "right". default is basis-1/2, but can be overrriden (see: Sidebars)Triplet
: a container comprised of 3 child containers with slot names "left", "middle" and "right". default is basis-1/3, but can be overrridenQuad
: a container comprised of 4 sub containers with slots named "tl", "tr", "bl", "br"HookPlug
: a simple container comprised of 2 sub containers with no styles with slot names "hook" for the first and "plug" for the second. used quite a lot by other componentsSidebarLeft
/SidebarRight
: simple extensions of the Split component that changes from basis-1/2 each to 1/4 and 3/4 to create a sidebar
Link
: simple link tag, supportingexternal
boolean prop to addtarget="_blank"
Img
: simple imageSvg
: simple Svg component reducing use to just passing the data as a prop. Note: this only supports the one implementation of Svgs for the social icons it was originally made from. Will need to add more supported props to be actually useful.List
: a simple list component, wrapping a list ofitems
text inListItem
componentsLinkList
: a simple extension supporting a list of{url:'',text:'',external:bool}
conforming objects being wrapped inLinkListItem
componentsListItem
: a simple li tag component. supports both the proptext
, and passing components to its unnamed slotLinkListItem
: an extension that formats each list item as a link.url
andexternal
must be set via props, but the content like ListItem supports both thetext
prop and an unnamed slot
Form
,Button
,Submit
,InputCheck
,InputText
,Label
: I haven't tested form stuff much, but to avoid a lot of repetition... these are what they sound likeFieldText
: field text is made up of aLabel
and anInputText
fieldFormTextCapture
: needs work, but used by thePlugCaptureForm
. intended to be a one liner form with input text + button... but has no button yet
Footer
: footer component supporting the props:address
,list1
,list2
,list3
andaddressLast
(a bool flag that puts the contact on the right instead of left)Navbar
/flattenMenu
: simple, opinionated navbar that usesflattenMenu
to take in any defined Tailwind classes and compile them (needs work, not a fan of how implementation tied it is atm)HeroSplit
: a simple extension of the Split that assumes you want an image in the right slot... not a great implementation but will likely get some improvements to keep a Hero component around
Card
: leverages HookPlug components within, supporting the propsimg
,hook
,plug
,footer
andsuper
/sub
, which would be relative the hookCardVisualHook
: supports the same props asCard
, but makes the image a background image and places the state in a container positioned according tostyles/components/global/structure/visualcard.json
PersonTitle
: simple component meant to place a name above a title/email/subtextSocialSignature
: component made up of an image to the left of aPersonTitle
componentContactCard
: similar to the SocialSignature, but passes a list containing title, email and phone to the title slot (via the nameless slot)Map
: a simple Google Map embed code taking in thesrc
URL as a propAddress
: component made to render an address from itsstreet
,city
,prov
andpostal
values. Note: prints "Address:" atm, but should optionally hide it.Hours
: takes in an object with keys being the lowercase names of the week, and values being a string rep of the hours to print.ContactCardCompany
: similar idea to theContactCard
, but supportsaddress
andhours
props as well, leveraging the above components if presentPlugCaptureForm
: meant to be a simple, single field form input. still a bit half baked with no button/not having tested any form components yet.
Attributes
: aims to define a list of valid HTML attributes that are permissible on HTML tags as to not spam arbitrary props into them. Atm its a function, but it should be rerolled as an interface because its way simpler.
flattenClasses
: aims to support the JSON based system of Tailwind rule management this project has ran with. These components follow a pattern of separating structure based rules from style based rules, while also supporting properties be overridden. The function expects:
- a
keys
array, defining which fields to pluck out structure
, which would usually be loaded fromstyles/components/global/structure
if a base component, orstyles/structure
if local to projectstyle
, which would usually be loaded fromstyles/components/global/style
if a base component, orstyles/style
if local to projectprops
, would usually just be passing the props, but could also be manipulated first. should override any structure/style rules, but have ran into cases where it hasn't, which is where theuniqueTailwindClass
function stemmed from. Will need to more fully test both functions.
- fix the super broken-ness of some components on mobile... they know who they are...
- circle back to Layout to just support whatever slots/imported state necessary to keep it generalized
- change Attributes to an interface and update references to
atts = props as IAttributes
accordingly. potentially worth breaking up interfaces by tag type, but could get weird - finish off navbar with required shared state components
- improve Svg component to make it more generally useful
- expand features for other HTML tag normative components to make them more useful/flexible
- dive more into Tailwind themes and its build order's impact on how styles are built from JSON definitions
- lots more, including improving these docs
- fork my own repo to add Web3 components? not sure they need to be in a base made more for web2, but I'll want them so they'll be added... somewhere
Its not pretty... but its almost structured, which is what I'm after :P. Thanks Guy McDude, aka shawunchander, for the pwa-starter. Definitley helped hit the ground running playing with Astro (and Tailwind for that matter). Note: that is a real business, with really delicious burgers, but those emails are definitely fake.