Skip to content
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

Issue#304: Detect all theme patterns. #318

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions modules/ui_patterns_library/src/Plugin/Deriver/LibraryDeriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,14 @@ public function getPatterns() {
/**
* Create a list of all directories to scan.
*
* This includes all module directories and directories of the default theme
* and all of its possible base themes.
* This includes all module and theme directories.
*
* @return array
* An array containing directory paths keyed by their extension name.
*/
protected function getDirectories() {
$default_theme = $this->themeHandler->getDefault();
$base_themes = $this->themeHandler->getBaseThemes($this->themeHandler->listInfo(), $default_theme);
$theme_directories = $this->themeHandler->getThemeDirectories();

$directories = [];
if (isset($theme_directories[$default_theme])) {
$directories[$default_theme] = $theme_directories[$default_theme];
foreach ($base_themes as $name => $theme) {
$directories[$name] = $theme_directories[$name];
}
}

return $directories + $this->moduleHandler->getModuleDirectories();
}
protected function getDirectories() {
return $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories();
}

/**
* Get extension name that hosts the given YAML definition file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
- name: 'simple'
label: 'Simple'
description: 'A simple pattern'
has_variants: false
preview: '<div class="pattern-simple">Simple pattern field</div>'
fields:
- name: 'field'
type: 'string'
label: 'Field'
description: 'Field description'

- name: 'with_variants'
label: 'With variants'
description: 'Pattern with variants'
has_variants: true
preview: ~
fields:
- name: 'field'
type: 'string'
label: 'Field'
description: 'Field description'
variants:
- meta:
name: 'one'
label: 'One'
description: 'First variant'
preview: '<div class="pattern-with-variant-one">With variants pattern field</div>'
- meta:
name: 'two'
label: 'Two'
description: 'Second variant'
preview: '<div class="pattern-with-variant-two">With variants pattern field</div>'

- name: 'with_custom_theme_hook'
theme hook: 'custom_theme_hook'
label: 'With custom theme hook'
description: 'Pattern with custom theme hook.'
has_variants: false
preview: 'With custom theme hook: Pattern field value'
fields:
- name: 'field'
type: 'string'
label: 'Field'
description: 'Field description'

- name: 'button'
label: 'Button'
description: 'A simple button.'
Expand Down Expand Up @@ -97,3 +52,48 @@
type: 'string'
label: 'Field'
description: 'Field description'

- name: 'simple'
label: 'Simple'
description: 'A simple pattern'
has_variants: false
preview: '<div class="pattern-simple">Simple pattern field</div>'
fields:
- name: 'field'
type: 'string'
label: 'Field'
description: 'Field description'

- name: 'with_variants'
label: 'With variants'
description: 'Pattern with variants'
has_variants: true
preview: ~
fields:
- name: 'field'
type: 'string'
label: 'Field'
description: 'Field description'
variants:
- meta:
name: 'one'
label: 'One'
description: 'First variant'
preview: '<div class="pattern-with-variant-one">With variants pattern field</div>'
- meta:
name: 'two'
label: 'Two'
description: 'Second variant'
preview: '<div class="pattern-with-variant-two">With variants pattern field</div>'

- name: 'with_custom_theme_hook'
theme hook: 'custom_theme_hook'
label: 'With custom theme hook'
description: 'Pattern with custom theme hook.'
has_variants: false
preview: 'With custom theme hook: Pattern field value'
fields:
- name: 'field'
type: 'string'
label: 'Field'
description: 'Field description'