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

Create a Card block content type #76

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

phenaproxima
Copy link
Owner

This is part of #12.

In a one-on-one chat, @larowlan and I felt that it would be a good idea to start adding some useful block types, even though we don't quite have a page layout system in Starshot yet. A card block type seems useful because, even if we don't have a decent layout system, cards might still make sense in the sidebar in some situations. There's no harm in building out the data model/fields now, even without any special affordance for layout.

Copy link

@simesy simesy left a comment

Choose a reason for hiding this comment

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

Semantic/reuse modelling review. This PR highlights two fields that (I would love if) Core somehow shipped opinionated versions of: a CTA link field, and a mixed media hero field.

@@ -106,7 +106,8 @@
"patches": {
"drupal/core": {
"#3444246: Create a config action to set the status of the entity": "./patches/core/recipes-103.patch",
"Add config actions to make a bundle of an entity type translatable": "./patches/core/make-translatable-action.patch"
"Add config actions to make a bundle of an entity type translatable": "./patches/core/make-translatable-action.patch",
"Give block content entities bundle-level permissions granularity": "./patches/core/block-content-granularity.patch"
Copy link

Choose a reason for hiding this comment

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

Should patches like this reference a drupal.org issue?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, but this one has no d.o issue. I just spun up the patch quickly.

If there is an existing issue with a patch (or you want to create one), let's use that.

Choose a reason for hiding this comment

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

Is there a core issue for this, feels like an oversight given we do have bundle perms for them since drupal.org/node/1975064

Copy link

@simesy simesy May 15, 2024

Choose a reason for hiding this comment

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

Yes, but this one has no d.o issue.

So if there is no #123456 in the patch description, then it is owned by the prototype (until it's not).

Copy link
Owner Author

Choose a reason for hiding this comment

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

More or less, yeah. The rules are loose; patches are completely internal, so we can name them however we want.

module:
- text
id: block_content.card.body
field_name: body
Copy link

Choose a reason for hiding this comment

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

I think if you're going to use field_ elsewhere then use it for everything, as other than being persistent "body" is just a field and shouldn't have special treatment.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Except that we're using the body field that ships with the block_content module, so it's kind of an inherited decision.

I don't feel super strongly but I'd rather not create new fields when we can reuse them.

Copy link

Choose a reason for hiding this comment

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

You can just delete the body field, it doesn't break anything. We shouldn't be limited by old core decisions of which this one isn't great.

Note that i advocate no field_ prefixing, which would make body good. https://www.youtube.com/watch?v=2495KafRZAg

Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't think we really need to get too hung up on the fields' internal names.

Starshot has no update path, so we can always change this later, whenever we want. I think it's safe to assume that end users probably won't care about the names; since Starshot is meant to put users first, I think it makes sense to merge this if the data model overall makes sense, and we can bikeshed the field names in a separate PR.

Copy link

Choose a reason for hiding this comment

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

We have to be mindful that decisions made 10 years set what people think is best practice. So we have to start a dialog about what we're pushing out (and have a way to defer gold plating without dropping the ball). I really would love to see a target content model done in Excalidraw or something so that we can measure PRs against it.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm in favor of developing some reasonable guidelines around field names, but this repository is a rapid prototype of Starshot developed mostly by fiat, with the goal of delivering as much value to end users as we can, as quickly as we can. So we can play a little fast and loose, at least for now. :)

dependencies:
config:
- block_content.type.card
- field.storage.block_content.field_card_link
Copy link

Choose a reason for hiding this comment

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

here "field_card_link" appears to have the intention of offering a call to action. This is a very generic thing and I would prefer to see a "field_ctalink" or field_cta_link or something like that can be reused - and hence if, for example, it is themed it is theme consistently. (Bearing in mind I don't yet know how well recipes will overlap with shared fields.)

Copy link
Owner Author

Choose a reason for hiding this comment

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

No objection to renaming the field. The machine names of these fields won't matter much to end users, and we can rename them whenever we want since there is no update path.

Choose a reason for hiding this comment

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

Personally I go with a generic 'link' if singular and 'links' if plural for maximum re-use and minimum number of DB tables.

- media.type.remote_video
- media.type.video
id: block_content.card.field_card_media
field_name: field_card_media
Copy link

Choose a reason for hiding this comment

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

Same comment as with link... Should it be reused? and media is singular and plural. The intention seems to be a single media item for displaying an image or a video. I often choose "hero" for this which is a very common and meaningful way to describe a single media instance that is canonical for an entity.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm okay with renaming this to field_hero.

Choose a reason for hiding this comment

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

I don't know that hero is correct here given there will be multiple cards in a card grid

Copy link
Owner Author

Choose a reason for hiding this comment

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

Echoing #76 (comment), I'd recommend we not get too deep into the weeds of how the fields are named -- at least not in this PR.

Copy link

@larowlan larowlan left a comment

Choose a reason for hiding this comment

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

This looks good, I think we should also think about a 'card reference' block type recipe (Separate PR) that would add the following:

  • new block type with a single ER field to a node
  • new card image field on all node types
  • new card teaser field on all node types
  • form display changes to put those in a details element in the sidebar on the node form
  • card view mode for all node types that used the node title, url, image, teaser to replicate the card block content type we're adding here

@@ -106,7 +106,8 @@
"patches": {
"drupal/core": {
"#3444246: Create a config action to set the status of the entity": "./patches/core/recipes-103.patch",
"Add config actions to make a bundle of an entity type translatable": "./patches/core/make-translatable-action.patch"
"Add config actions to make a bundle of an entity type translatable": "./patches/core/make-translatable-action.patch",
"Give block content entities bundle-level permissions granularity": "./patches/core/block-content-granularity.patch"

Choose a reason for hiding this comment

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

Is there a core issue for this, feels like an oversight given we do have bundle perms for them since drupal.org/node/1975064

dependencies:
config:
- block_content.type.card
- field.storage.block_content.field_card_link

Choose a reason for hiding this comment

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

Personally I go with a generic 'link' if singular and 'links' if plural for maximum re-use and minimum number of DB tables.

- media.type.remote_video
- media.type.video
id: block_content.card.field_card_media
field_name: field_card_media

Choose a reason for hiding this comment

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

I don't know that hero is correct here given there will be multiple cards in a card grid

@phenaproxima
Copy link
Owner Author

I think we should also think about a 'card reference' block type recipe (Separate PR)

@larowlan, can you open a separate issue or PR for that?

@phenaproxima
Copy link
Owner Author

As of #77, I think we might want to start using Type Tray for the block types, and ship some icons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants