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

Patterns: show theme patterns from directory in site editor #55877

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Changes from 1 commit
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
1 change: 0 additions & 1 deletion packages/patterns/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const PATTERN_CORE_SOURCES = [
'core',
'pattern-directory/core',
'pattern-directory/featured',
'pattern-directory/theme',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this makes the PATTERN_CORE_SOURCES variable name no longer true, so perhaps the variable needs to be renamed as well (EXCLUDED_LIBRARY_SOURCES?), or the filtering could be done a different way.

Copy link
Contributor Author

@glendaviesnz glendaviesnz Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it actually applies better now as previously it included theme specified patterns from the directory which are essentially theme patterns rather than core, now it is more strictly just core patterns that are not related to the current theme at all.

Having looked at the places where PATTERN_CORE_SOURCES is currently used the name still seems to fit in the context - but happy to rename if you still think it is not a suitable name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @talldan on the naming here.

previously it included theme specified patterns from the directory which are essentially theme patterns rather than core

The source of the patterns is core and the pattern directory, not the theme. The theme doesn't create or define the patterns, it only "opts into" using them, which doesn't change their actual source.

Copy link
Contributor Author

@glendaviesnz glendaviesnz Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it confuses things to not think of these as theme patterns - from the user perspective they are a theme pattern regardless of the source, but I will try and come up with a name for the constant that better reflects the situation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the user perspective they are a theme pattern regardless of the source

Luckily, we're referring to a variable name here that isn't exposed to users, so we can afford to be accurate.

We could also argue that for most users they only see patterns, not user, theme, or core patterns etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the new naming of NON_THEME_PATTERN_SOURCES introduced in 316bc22 is any better than PATTERN_CORE_SOURCES. As discussed, the source is still the pattern directory not the theme, so NON_THEME_PATTERN_SOURCES should still include pattern-directory/theme in my view.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have renamed the constant to NON_THEME_PATTERN_SOURCES, which makes the nature of it a bit clearer in the contexts it is used I think, eg.

const selectThemePatterns = createSelector(
...
    .filter( ( pattern ) => ! NON_THEME_PATTERN_SOURCES.includes( pattern.source ))
...
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dan's suggested name EXCLUDED_LIBRARY_SOURCES sidesteps most of the discussed issue by naming the array by its purpose. It might require an extra tweak to an inline comment and variable but that's neither here nor there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have updated that inline comment and variable

];
export const PATTERN_SYNC_TYPES = {
full: 'fully',
Expand Down
Loading