Component Folder Structure

Created on 22 August 2024, 6 months ago
Updated 17 September 2024, 5 months ago

Problem/Motivation

We discussed revamping the component folder structure, this goal it to streamline some development and make it easier to understand component structure within Prototype.

Proposed resolution

Following a similar structure to this

/components
	/00-base // NO Selectors - loaded globally
    base.twig
		base.stories.twig
    base.md
    /src
	  base.scss
	  _breakpoints.scss
	  _colors.scss
      _layout.scss 
	  _typography.scss
	  _spacing.scss
	  _radius.scss
	/01-elements // HTML tag selectors - loaded globally
		elements.stories.twig
		/src
		  elements.scss
          _headings.scss // h1-h6
          _forms.scss // button, form, input, select
          _links.scss // a
		  _lists.scss // ul, ol, li, dl, dt, dd
		  _media.scss // audio, img, figure, video
		  _tables.scss // table, thead etc.
		  _text.scss // blockquote, p
	/02-components // Component loaded (SDC)
    /component-1
    /component-2
		/teaser
			/teaser-variant1
			/teaser-variant2
	/03-layouts // Structural components - Component loaded
		/column
		/grid
	/04-pages // Component loaded
		/403
		/404
		/basic
		/landing
		/login
		/homepage
		/search
	/05-regions // Component loaded
		/site-header
		/site-footer
	/06-utilities // Utility classes - loaded globally
		_stack.scss
	/07-overrides // Overrides - loaded in library.yml
		/flag
		/webform
		/views
/libraries // Flattened
  /global
  /partials
    _animations.scss
    _breakpoints.scss
    _calculations.scss
    _layout.scss
    _lists.scss
	_media.scss
	_partials.scss
    _spacing.scss
    _typography.scss
/vendor
πŸ“Œ Task
Status

Needs review

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jldust

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jldust
  • πŸ‡ΊπŸ‡ΈUnited States philip_stier Denver, Colorado

    @jldust / @pixelwhip - Is there any downsides to having all of the partials nested inside the 00-base directory? If we're trying to consolidate, why not everything, right? This would effectively negate the need for the 'libraries' directory.

  • πŸ‡ΊπŸ‡ΈUnited States philip_stier Denver, Colorado

    @jldust / @pixelwhip - Thinking in idealogical order, do you think the pages directory and the regions directory should be switched? So:

    /04-regions
    /05-pages

  • πŸ‡ΊπŸ‡ΈUnited States philip_stier Denver, Colorado

    @jldust / @pixelwhip - Also, do you think any of the 06-utilities can just go under 00-base/global?

  • Status changed to Needs review 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jldust
  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jldust

    Notes from our meeting:
    - Move components nested in elements to the 02-components folder
    - Move SCSS files within the respected nested 00 folders brought up in discussion

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States pixelwhip

    Rebased the merge request onto the latest 5.x.

  • πŸ‡ΊπŸ‡ΈUnited States pixelwhip

    Closed and reopened the merge request to get tugboat to rebuild.

  • πŸ‡ΊπŸ‡ΈUnited States pixelwhip

    @jldust & @philip_stier I've made some updates to this and it's ready for review again.

    1. Moved any element selectors to the 01-elements
    2. Moved layouts in 03-layouts
    3. Moved the regions to 04-regions
    4. Adjusted the cypress tests to work with the new structure.
    5. Updated the libraries.yml file to match
  • Status changed to Needs review 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States pixelwhip
  • Assigned to pixelwhip
  • πŸ‡ΊπŸ‡ΈUnited States jldust

    Thanks for making those updates, this is getting pretty close.

    We have a few outstanding thoughts/questions:

    • With the update to layouts.scss should the root selectors be moved into 00-base and then move the other pieces into their own sections within the 03-layouts folder. (IE flex, container)
    • For the page directory should we add a base SCSS file for each of those folders and then load it in the libraries file? (Example: basic/basic.scss)
  • πŸ‡ΊπŸ‡ΈUnited States pixelwhip

    Good catch on the :root styles. I did wonder about those. I think the only time :root styles outside of 00-base are appropriate is if they are component specific. In which case they should be namespaced as --prototype-[component-name]-[property]. I thought that was a little ambiguous with the grid and width custom props. I had to ask if these properties could be applicable outside of the context of those utility classes and figured they could be, but am not 100% convinced. I moved them for now for consistency sake. I also updated the grid property to leverage the spacing props.

    I added a blank stylesheet for the page template. I removed the landing page folder as I don't think we should have more than one example folder without a corresponding template. Otherwise it's more stuff that may need to be deleted. It probably is a good idea to have a starter landing page template with corresponding styles but that could be another issue.

  • πŸ‡ΊπŸ‡ΈUnited States pixelwhip

    Rebased onto the latest from 5.x.

  • Pipeline finished with Skipped
    5 months ago
    #299290
  • πŸ‡ΊπŸ‡ΈUnited States jldust

    This looks great, thanks for all the work on getting the folder structure updated. This will be included in the next tagged release.

  • πŸ‡ΊπŸ‡ΈUnited States jldust
Production build 0.71.5 2024