-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#44] Implement Blueprint Elements #46
Conversation
Uses `vite-plugin-static-copy` to copy SVGs from src/icons Macro inlines SVG files into page.
@@ -32,7 +32,7 @@ web_extra_exposed_ports: | |||
web_extra_daemons: | |||
# Run vite in a separate process | |||
- name: 'vite' | |||
command: 'npm install && npm run dev' | |||
command: 'npm install && npm run build && npm run dev' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensures that icons are present on start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this works. I had been trying to work around this by either using src/public
or the Vite HMR Public Copy plugin — this will work, but I think it won't catch additions or changes you make to that folder while working unless you ddev restart
(since this is in a daemon and not a terminal tab where R
would reload Vite) — right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... you know what. I got thrown off by the name.
I thought it would only copy the public
directory. But it seems like you can configure it to copy any directory?
I was hesitant to use the public
directory for icons, because on some of our more complex sites, we occasionally need to reference icons from JS.
I'll put in a ticket to look into this more deeply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -30,3 +30,6 @@ CRAFT_SECURITY_KEY= | |||
CRAFT_DEV_MODE=true | |||
CRAFT_ALLOW_ADMIN_CHANGES=true | |||
CRAFT_DISALLOW_ROBOTS=true | |||
|
|||
# Asset Settings | |||
ASSET_FILESYSTEM=local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, the env var would let you choose s3 or local depending on your environment or preference.
Future ticket for some default AWS setup
@@ -0,0 +1,107 @@ | |||
import plugin from 'tailwindcss/plugin' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact copy of blueprint (only change was to make an ES Module)
config/tailwind/dialog.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact copy of blueprint (only change was to make an ES Module)
@@ -1,8 +1,47 @@ | |||
import buttons from './config/tailwind/buttons' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mirroring the TW config of blueprint
@@ -0,0 +1,48 @@ | |||
{# @var string|null title #} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corresponding Blueprint Component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only change was to use Alpine for dismissible variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious to hear everyone's thoughts on this.
It's using Imager X's power pack, but wraps that abstraction so if you ever change your image plugin, you don't have to rip it out everywhere.
Main goals for this component.
- Minimize the amount of transform config you need to spread around your project.
- Reduce the Imager X specific syntax in your project (would make it easier to switch from Imager X if needed).
- Use TW screen names in your sizes props.
ppimg() is doing some interesting stuff here.
Here's some further detail on the fillTransforms setting.
{% set minWidth = 320 %}
{% set maxWidth = 2200 %}
{{ image ? ppimg(
image: image,
transform: [
minWidth,
maxWidth, // [1.] Generate transforms between 320 and 2200
{
ratio: ratio,
},
],
params: {
class: cx(class, 'w-full h-auto'),
loading,
fillTransforms: 'auto', // [2.] By using fillTransforms 'auto' we fill in between our min/max widths
autoFillCount: 5, // [3.] Creates 5 transforms evenly spaced between our min/max widths
allowUpscale: false,
sizes: sizes,
},
) }}
templates/_components/tag.twig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical to Blueprint minus the ability to use slots.
templates/_components/video.twig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical to Blueprint
I think over time our clients would benefit from the following:
- lazy load the iframe
- customizable thumbnail / play button
We also might want to consider using a plugin that parses URLs to get the video ID/Embed URL.
templates/_macros/icon.twig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple wrapper around the svg
function in Craft.
Inlines the SVG markup directly into the page.
Provides some icon sizing logic so you don't have to remember to pass size-xyz
everywhere. Although there is the option to pass none
as the size and use your own TW classes in unique scenarios.
plugins: [ | ||
viteStaticCopy({ | ||
targets: [{ src: 'src/icons/**/*', dest: './assets/icons' }], | ||
}), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we handle icons on MW and it works pretty well.
Open to other suggestions too. I considered putting them in the public
directory. But you loose the ability to bundle SVG with your JS.
4fd734d
to
abde8cc
Compare
{% set screens = { | ||
'sm': '(min-width: 640px)', | ||
'md': '(min-width: 768px)', | ||
'lg': '(min-width: 1024px)', | ||
'xl': '(min-width: 1280px)', | ||
'2xl': '(min-width: 1536px)', | ||
} %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On some sites (like MW), we actually convert our TW config to JSON and then load it via PHP so we can get at these values.
But.... I'm of the impression lately that it a ton of complexity to save us 5-ish lines of code.
Do screen sizes really change all that much after a project has been started? This might be an acceptable DUPE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
templates/_components/card-icon.twig
Outdated
{% if title or description %} | ||
<div class="flex flex-col gap-8"> | ||
{% if title %} | ||
<h2 class="text-xl font-bold">{{ title }}</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This H2 should could probably be a variable. I'm also wondering if H3 is a better default if a typical page structure looks like:
H1 Page Title
|- H2 My Card List
|- H3 Card Title
|- H3 Card Title
|- H3 Card Title
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! I'll update in my next PR
{% if title or description %} | ||
<div class="flex flex-col gap-8"> | ||
{% if title %} | ||
<h2 class="text-xl font-bold">{{ title }}</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question re: heading.
- Adds TW class for default site max width
- Uses both image & icon cards
- Update cards & buttons to use new window.
- Simple is just Bold, Italic, Underline plus links - Advanced has more options like headings, styles, lists, etc.
Whoops :)
The nav has a max depth of 3 levels. This simplifies our markup since it doesn't have to be recursive
The desktop and mobile nav markup will be their own partials.
Instead of using a focus trap, we focus on the first element in the sub nav, but allow you to tab out of the list. When focus leaves, we pop the subnav.
Overview:
/src/icons/
directoryI've left comments on most of the components