Coder Social home page Coder Social logo

craft-viget-base's Introduction

Craft Viget Base Module

Docs

craft-viget-base's People

Contributors

davist11 avatar gregkohn avatar jjimmyflynn avatar joshuapease avatar maxfenton avatar nevinsm avatar olets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

craft-viget-base's Issues

[Parts Kit] Add auto-generated icons grid

This seems like a nice touch to do from here bc we can grab all of the icons from a specified dir more easily in PHP.

My motivation is being able to glance through these visually, sometimes the names just don't quite do it

Add parts kit tests

  • Generating the correct nav
  • Can grab a craft asset
  • Is a parts kit request
  • Correctly selects dark theme config if 'theme' => 'dark' is passed
  • Correctly outputs custom theme CSS

[CLI Generator] Initial functionality

Overview

Helps cut down on busywork and stick to team standards.

We're calling this a generator to line up with Yii/Gii naming conventions.

Core Features

  • Can create partials / w corresponding parts-kit files
  • Can create a basic template with example "best practices"
  • Can reference a section handle and create corresponding templates for each entryType

Stretch Goals

  • Can create an section and entryTypes via the CLI (optionally create templates too) #38

[Parts Kit] Use localStorage to preserve accordion state

As a SPA, Storybook has a nice behavior where accordion state is preserved as you navigate components. I think this presents a far better experience because things aren't jumping around. Syncing state to localStorage should do it...but perhaps this is a can of worms with the slide animation on load -- would need to bypass it

Blitz caching the Edit Entry button

The red "Edit Entry" sometimes ends up in Blitz or CDN cached versions of the site.

We should explore a few different options to prevent this from happening when content editors view the front-end of the site.

There are a few caching layers

  • Blitz's caching (stored as files on the server or in Yii's Cache).
  • CDN caching (Cloudflare or Cloudfront sitting in front of the site). These are separate and unaware of Blitz or Craft internals. All that the Blitz integration does is invalidate these caches when content changes.
    • It's often possible to prevent these services from caching by passing the appropraite no-cache/store headers

Change to Viget.com module code (no-cache headers for admins)

Details:
Across a few sites that use this module with the Blitz plugin (e.g. ADC-AMH, Viget) sometimes the Edit Entry button gets cached in the Blitz static cache for all users.

It was a misunderstanding that Blitz automatically does not cache or serve cached assets to signed-in users, but in looking at the source code the logic is as follows:

Blitz is only checking:

  • is the site turned off but the user can see it anyway? ($user !== null) && (!Craft::$app->getIsLive() && !$user->can('accessSiteWhenSystemIsOff'))
  • does the user have the debug toolbar open ($user !== null) && ($user->getPreference('enableDebugToolbarForSite'))
  • does the page say not to cache it (admin area etc) using (!empty($request->getParam('no-cache')))
  • page has a token ($request->getToken() !== null && !$this->getIsGeneratorRequest())

During development, Viget developers (cough me) have the debug toolbar visible so the caching issue was not immediately evident or consistent. Seeing that this Blitz logic checks for the no-cache header, add a no-cache header to all pages that show the Edit Entry button

Looking at the Craft 4 code for Response there may be a public function setNoCacheHeaders() or else the module might need to do something like

$request = Craft::$app->getRequest();
$request->setHeader('Pragma', 'no-cache', true);

Ref:

Get Tests Working Again

  • Switch from Circle CI to GitHub Actions
  • Switch from docker-composer to DDEV (for local test runs and composer installs)

Check if Craft is installed before adding Phone Home job

I'm seeing an issue where the Phone Home job is attempting to push its job into the queue when Craft is not installed. This causes an exception because the queue table doesn't exist, and makes it impossible to access the installer via the web UI.

(Not sure what else this repo does, so might be worth making sure there isn't other code in here that should only run when Craft is installed.)

Custom SEO Field

Should we make a custom SEO field that has:

  • Meta Title (plain text)
  • Meta Description (plain text)
  • Meta Image (asset)

Then some ability in the template to override those values with some defaults per entry template

{% set meta = craft.viget.meta(entry, options) %}

Where options is an object where you can set a field to use for title/description/image if nothing is set in the field

[Improvement] Add a clearer error message regarding Tailwind JSON

Bug that prompted this ticket

Overview:

Craft projects can optionally import a JSON encoded version of a project's TW config.

Most often, we use these TW config values in Twig:

  • Use Tailwind's screens key/value pairs in a component so we can use values like sm, md, etc to get a configured media query. MW's image macro uses it so that srcset/sizes code is kept in sync with Tailwind's breakpoints (it also saves writing out full media queries).
  • Automatically displaying config values like colors & sizes in our parts kit (see MW again).

Decision points
We need to decide if we want a hard error on every page or some other kind of warning.

I think an exception is still necessary, but a clearer error message that explains what the file is for and why it's not there would be a useful improvement.

If template code depends on a JSON file being there, it probably makes sense to know right away rather than have unexpected behavior, or exceptions on only a handful of pages that might make calls to TW.

One frustrating thing about the current implementation is that it always looks for a JSON file and throws even if you aren't using it in your config.

We may want to make this an opt-in feature. However, that would probably be a breaking change.

[CLI Generator] Create Sections & Entrytypes via the CLI

Calling a command like this...

craft viget-base/generate section resources --types="caseStudy, webinar, glossary"

Will create a new section in the Craft admin with corresponding entry types.

The appropriate templates will also be created in templates/_elements/

If there are multiple entry types, the pattern will be templates/_elements/sectionName/index.html with corresponding files for each entry type.

Add support for Collections

Util::fillInEntries() expects an array of entries. However, with Craft 4 going all in on Collections, it probably makes sense to support that type as well.

Automate index.html behavior?

easiest: add documentation about adding an index.html
other ideas

  • route to first component automatically
  • provide sample for manual redirect
  • anything else?

support deeply nested colors in tailwind service

Tailwind supports deeply nested colors; our Tailwind service doesn't. Changing getColors to use a recursive function would add support for deeply nested colors.

Example: the AHIP design system has things like "blue" and "dark blue", which we set up as

      blue: {
        DEFAULT: '#5fb1c3',
        // … several levels of blue
        dark: {
          DEFAULT: '#004b66',
          // … several levels of dark blue
        },
      },

Rename "Phoning home" queue item

Description

When the "Phoning home" queue item runs, it's not clear to non-Viget users what that is. It would be great to make that item's name more descriptive. Maybe something like "Phoning home - Viget"? Just so that if people have questions about it, they'll have a thread to grab onto.

Prioirty: Low (is there something lower than low priority? If there were...this would be it.)

[Idea] Add command palette/fuzzy search functionality to parts kit

I'm certainly not trying to make the parts kit pages too heavy so I'm not 100% convinced this is a great idea but i have ~50 components in my Trust parts kit and ~100 overall variations. Would be nice to have a quick way to filter these down, whether via a search functionality identical to Storybook's or a modal similar to a command palette.

Storybook's implementation, which updates live as you type:
image
Example link: https://code.viget.com/spb-insider/?path=/story/achievement-icon--incomplete

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.