-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#65] Adds ability to use new version of parts kit
- Loading branch information
1 parent
8469890
commit a64bff4
Showing
6 changed files
with
212 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace viget\base\models; | ||
|
||
use yii\base\BaseObject; | ||
|
||
class PartsKitNavItem extends BaseObject | ||
{ | ||
public string $title; | ||
public string $url; | ||
public array $children = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,134 @@ | ||
{% extends craft.viget.partsKit.getConfig('layout') %} | ||
|
||
{% block content %} | ||
<style> | ||
.parts-kit { | ||
{{ craft.viget.partsKit.getTheme() }} | ||
} | ||
</style> | ||
{% set partsKitVersion = craft.app.request.getParam( | ||
'version', | ||
craft.viget.partsKit.getConfig('version') | ||
) %} | ||
{% set isPartsKitRoot = craft.viget.partsKit.isRoot() %} | ||
|
||
{# Allows us to use the main block in multiple branches #} | ||
{% set main %} | ||
{% block main %}{% endblock %} | ||
{% endset %} | ||
|
||
<div class="parts-kit" data-parts-kit data-turbo="false"> | ||
<aside | ||
class="parts-kit__sidebar" | ||
data-sidebar | ||
> | ||
<h2 class="parts-kit__sr-only">Parts Navigation</h2> | ||
{% block content %} | ||
{% switch(partsKitVersion) %} | ||
{% case 1 %} | ||
<style> | ||
.parts-kit { | ||
{{ craft.viget.partsKit.getTheme() }} | ||
} | ||
</style> | ||
|
||
<label class="parts-kit__sr-only" for="pk-search">Search parts kit</label> | ||
<div class="parts-kit__search"> | ||
<input class="parts-kit__search-input" | ||
id="pk-search" | ||
type="search" | ||
placeholder="Press / to search..." | ||
data-focus-placeholder="Type to search..." | ||
data-sidebar-search | ||
<div class="parts-kit" data-parts-kit data-turbo="false"> | ||
<aside | ||
class="parts-kit__sidebar" | ||
data-sidebar | ||
> | ||
{{ svg('@viget/base/resources/icons/search.svg') | attr({ | ||
class: 'parts-kit__search-icon', | ||
}) }} | ||
</div> | ||
<h2 class="parts-kit__sr-only">Parts Navigation</h2> | ||
|
||
{% set navSections = craft.viget.partsKit.getNav() %} | ||
<label class="parts-kit__sr-only" for="pk-search">Search parts kit</label> | ||
<div class="parts-kit__search"> | ||
<input class="parts-kit__search-input" | ||
id="pk-search" | ||
type="search" | ||
placeholder="Press / to search..." | ||
data-focus-placeholder="Type to search..." | ||
data-sidebar-search | ||
> | ||
{{ svg('@viget/base/resources/icons/search.svg') | attr({ | ||
class: 'parts-kit__search-icon', | ||
}) }} | ||
</div> | ||
|
||
{% if navSections %} | ||
<ol class="parts-kit__nav"> | ||
{% for title, section in navSections %} | ||
{% set id = "nav-section-#{loop.index}" %} | ||
{% set navSections = craft.viget.partsKit.getNav() %} | ||
|
||
<li data-parts-kit-toggle | ||
{% if section.isActive %}data-active-section{% endif %} | ||
> | ||
{% if navSections %} | ||
<ol class="parts-kit__nav"> | ||
{% for title, section in navSections %} | ||
{% set id = "nav-section-#{loop.index}" %} | ||
|
||
<li data-parts-kit-toggle | ||
{% if section.isActive %}data-active-section{% endif %} | ||
> | ||
<button | ||
class="parts-kit__button parts-kit__nav-button" | ||
aria-controls="{{ id }}" | ||
aria-expanded="{{ section.isActive ? 'true' : 'false' }}" | ||
> | ||
<div class="flex"> | ||
{{ svg('@viget/base/resources/icons/caret.svg') | attr({ | ||
class: 'parts-kit__nav-caret', | ||
}) }} | ||
{{ svg('@viget/base/resources/icons/pk-component.svg') | attr({ | ||
class: 'parts-kit__nav-component', | ||
}) }} | ||
<h3>{{ title | title }}</h3> | ||
</div> | ||
</button> | ||
|
||
<ol | ||
class="parts-kit__nav-sub-items {% if not section.isActive %}collapsed{% endif %}" | ||
id="{{ id }}" | ||
data-togglee | ||
> | ||
{% for item in section.items %} | ||
<li data-section-item | ||
data-search-text="{{ title ~ ' ' ~ item.title }}" | ||
> | ||
<a | ||
href="{{ url(item.url) }}" | ||
{% if item.isActive %}class="active"{% endif %} | ||
> | ||
<div class="flex"> | ||
{{ svg('@viget/base/resources/icons/pk-sidebar.svg') | attr({ | ||
class: 'parts-kit__nav-story', | ||
}) }} | ||
{{ item.title }} | ||
</div> | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
{% endif %} | ||
</aside> | ||
|
||
<div class="parts-kit__main"> | ||
<div class="parts-kit__main-wrapper"> | ||
<div class="parts-kit__main-header"> | ||
<button | ||
class="parts-kit__button parts-kit__nav-button" | ||
aria-controls="{{ id }}" | ||
aria-expanded="{{ section.isActive ? 'true' : 'false' }}" | ||
class="parts-kit__button hidden hover:text-robins-egg" | ||
data-fullscreen-expand | ||
> | ||
<div class="flex"> | ||
{{ svg('@viget/base/resources/icons/caret.svg') | attr({ | ||
class: 'parts-kit__nav-caret', | ||
}) }} | ||
{{ svg('@viget/base/resources/icons/pk-component.svg') | attr({ | ||
class: 'parts-kit__nav-component', | ||
}) }} | ||
<h3>{{ title | title }}</h3> | ||
</div> | ||
<span class="parts-kit__sr-only">Expand</span> | ||
{{ svg('@viget/base/resources/icons/pk-expand.svg') }} | ||
</button> | ||
|
||
<ol | ||
class="parts-kit__nav-sub-items {% if not section.isActive %}collapsed{% endif %}" | ||
id="{{ id }}" | ||
data-togglee | ||
<button | ||
class="parts-kit__button hidden hover:text-robins-egg" | ||
data-fullscreen-close | ||
> | ||
{% for item in section.items %} | ||
<li data-section-item | ||
data-search-text="{{ title ~ ' ' ~ item.title }}" | ||
> | ||
<a | ||
href="{{ url(item.url) }}" | ||
{% if item.isActive %}class="active"{% endif %} | ||
> | ||
<div class="flex"> | ||
{{ svg('@viget/base/resources/icons/pk-sidebar.svg') | attr({ | ||
class: 'parts-kit__nav-story', | ||
}) }} | ||
{{ item.title }} | ||
</div> | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
{% endif %} | ||
</aside> | ||
|
||
<div class="parts-kit__main"> | ||
<div class="parts-kit__main-wrapper"> | ||
<div class="parts-kit__main-header"> | ||
<button | ||
class="parts-kit__button hidden hover:text-robins-egg" | ||
data-fullscreen-expand | ||
> | ||
<span class="parts-kit__sr-only">Expand</span> | ||
{{ svg('@viget/base/resources/icons/pk-expand.svg') }} | ||
</button> | ||
<button | ||
class="parts-kit__button hidden hover:text-robins-egg" | ||
data-fullscreen-close | ||
> | ||
<span class="parts-kit__sr-only">Close</span> | ||
{{ svg('@viget/base/resources/icons/close-circle.svg') }} | ||
</button> | ||
</div> | ||
<span class="parts-kit__sr-only">Close</span> | ||
{{ svg('@viget/base/resources/icons/close-circle.svg') }} | ||
</button> | ||
</div> | ||
|
||
<div class="parts-kit__main-container"> | ||
{% block main %}{% endblock %} | ||
<div class="parts-kit__main-container"> | ||
{{ main }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% case 2 %} | ||
{% if isPartsKitRoot %} | ||
{# If we're at the parts kit root, render the parts kit chrome #} | ||
<script type="module" src="https://unpkg.com/@viget/parts-kit@^0/lib/parts-kit.js"></script> | ||
<parts-kit config-url="{{ craft.viget.partsKit.getConfig('configUrl') }}"></parts-kit> | ||
{% else %} | ||
{# Just render the block, no chrome #} | ||
{{ main }} | ||
{% endif %} | ||
{% endswitch %} | ||
{% endblock %} |