Volto add-on#
Everything @plonegovbr/volto-social-media adds to a Volto project.
The package#
Name |
|
Developed against Volto |
19.4.1 |
Peer dependencies |
|
Dependencies |
|
Every module named on this page is imported from the package, as in @plonegovbr/volto-social-media/components/SocialNetworks/SocialNetworks.
Note
Every component in this package has a story. Browse them in Storybook to see a component rendered with its props, without running a site.
Configuration#
The add-on's default export applies these steps, in this order.
Step |
Module |
Registers |
|---|---|---|
Blocks |
|
The Follow Us block |
Networks |
|
One |
Settings |
|
The |
Widgets |
|
The |
Slots |
|
The |
Expansion on content requests#
The add-on adds one entry to config.settings.apiExpanders.
Entry |
What it does |
|---|---|
|
Asks for the |
inheritQuerystring, exported by config/settings, appends the behavior's name to the expand.inherit.behaviors value built by the expanders registered before it.
The behaviors another add-on asked for, such as Volto Light Theme, are kept.
The entry matches every path, and is sent for anonymous visitors too. Endpoints and expansions describes the response.
Networks#
Each network is a utility of the type socialNetwork, named for the id a link stores.
Its method returns a SocialNetworkInfo object: id, title, and icon, an imported SVG.
|
|
|---|---|
|
BlueSky |
|
Discord |
|
Docker |
|
|
|
Flickr |
|
GitHub |
|
Gitlab |
|
|
|
|
|
Mastodon |
|
Medium |
|
RSS |
|
Slack |
|
Soundcloud |
|
Spotify |
|
StackOverflow |
|
Telegram |
|
Threads |
|
TikTok |
|
Twitch |
|
Website |
|
|
|
X (Twitter) |
|
|
|
YouTube |
A link whose id names no registered utility keeps its list item and its anchor, but renders no icon.
Widgets#
Registry |
Name |
Component |
|---|---|---|
|
|
|
|
|
|
|
|
|
The backend asks for social_media_object_list on both social_links fields, as The widget shows.
The Follow Us block asks for it on its allowedNetworks field.
A content view picks a view widget by the field's name, or by a widget set in a frontend schema.
It does not read the widget the backend names in frontendOptions.
So the view widget is also registered for the field name social_links.
The edit widget#
SocialLinksWidget is OrderedObjectListWidget with three props set.
Prop |
Value |
What it does |
|---|---|---|
|
|
Shows a link by its network and its title. |
|
|
Shows the network by its icon, named with the network's title. A network with no registered utility shows its |
|
|
Gives a link saved with an empty title the network's title. Changes nothing when the item schema has no |
Both widgets are exported by components/Widgets/OrderedObjectListWidget/OrderedObjectListWidget, the second as the default export.
The widget renders a list of objects as a table, one row per entry.
Action |
What it does |
|---|---|
Drag a row by its handle |
Moves the entry. Handles appear once Volto's drag-and-drop libraries have loaded. |
Edit |
Opens the entry in a dialog built from the item schema. |
Delete |
Asks for confirmation, then removes the entry. |
The button beside the field's label |
Opens an empty dialog for a new entry. Its label is Add followed by the title of the item schema. |
Every action changes the field's value only. Nothing is stored until the form is saved. An empty list shows Nothing has been added yet.
Prop |
Set by |
What it does |
|---|---|---|
|
|
Names a registered |
|
A form schema built in the frontend |
The item schema, or a function returning it. Ignored when it has no |
|
|
The fields of the item schema shown as columns, in order. |
|
A frontend component |
A function per field name, called with the entry's value and the whole entry, returning what the cell shows. Other columns show the value as text. |
|
A frontend component |
Called with the entries and the item schema after any change, returning the entries to store. |
|
Volto's form |
Removes the handles and disables every action. |
A schema function is called with the props of the widget spread, and also with props and intl as keys.
The dialog picks the widget of a field as object_list does, never by the field's name.
A field named id renders the widget its widget or choices asks for, rather than Volto's short name widget.
The value is a list of objects, in order.
Any change gives an @id to each entry without one, as Volto's object_list widget does.
The view widget#
SocialLinksViewWidget, exported by components/Widgets/SocialLinksViewWidget/SocialLinksViewWidget.
Prop |
What it does |
|---|---|
|
The links. |
|
Added to the wrapper's classes. |
It renders nothing for a missing or empty value.
Otherwise it renders a div with the classes social-links widget, holding SocialNetworks without animation.
Volto's DefaultView renders each field of a content object without blocks with its view widget.
The Follow Us block#
Key |
Value |
|---|---|
|
|
|
Follow Us Block |
|
|
|
Volto's |
|
|
|
|
|
|
|
|
Data#
A block stores a FollowUsBlockData object.
Key |
Type |
Sidebar fieldset |
Sidebar default |
Description |
|---|---|---|---|---|
|
string |
Default |
|
The headline above the icons. |
|
boolean |
Default |
|
Whether the icons move on hover. |
|
|
Filter Networks |
|
The networks shown, in this order. |
|
string, or an object of CSS custom properties |
Styling |
|
The block's alignment, set with the |
The sidebar edits allowedNetworks with the social_media_object_list widget, showing the one column id.
Its choices are the networks of the links the page inherits, not every registered network.
Rendering#
The block renders a container with the classes
block follow_us, and the class name Volto passes it.The headline renders in a container with the classes
follow_us title, whentitleis set.The icons are the links
useNetworksreturns forallowedNetworks.A block without an
animatekey animates its icons.
Slots#
Slot |
Name |
Component |
|---|---|---|
|
|
|
Volto Light Theme renders the followUs slot inside its post-footer, when the links the page inherits are not empty.
Components#
Module |
Props |
Renders |
|---|---|---|
|
|
A |
|
|
Volto's |
|
|
Volto's |
|
|
A container with the class |
|
|
The links |
|
|
The block, as The Follow Us block describes. |
|
|
The block's view, and its settings in the sidebar while it is selected. |
|
|
The page's head tags, as Shadowed component lists. |
The add-on registers FooterLinks nowhere.
Hooks#
useSocialMedia(), fromhooks/useSocialMediaThe
plonegovbr.socialmedia.settingsfields the current content inherits, as aSocialMediaSettingsobject. When none were served, it returnsDEFAULT_SOCIAL_MEDIA_SETTINGS:share_social_dataistrue, and every other field is empty.useNetworks(allowedNetworks = []), fromhooks/useNetworksThe links to show. They are the inherited
social_links, read throughuseLiveData. When those are empty, they areconfig.settings.socialNetworks, or an empty list. A non-emptyallowedNetworkskeeps only the links of those networks, in its order, and drops a network with no link. Of several links to the same network, it keeps the last.useLiveData(content, behavior, field), fromhooks/useLiveDataOne field of an inherited behavior. While a content form holds a field of that name, it returns the form's value, so a change shows before it is saved. Otherwise it returns the value the
inheritexpansion served. It matches the form's field by name alone.
Helpers and constants#
The networks are a client-side vocabulary, read from the registered socialNetwork utilities each time a function of vocabularies/networks is called.
getNetworks(), fromvocabularies/networksEvery registered network, as
SocialNetworkInfoobjects ordered by title.getNetwork(id), fromvocabularies/networksThe network a token names, or
undefinedwhen no utility is registered for it.networkChoices(), fromvocabularies/networksThe networks as
[id, title]pairs, ordered by title, for thechoicesof a select field.networkTitle(id), fromvocabularies/networksThe network's title, or
iditself when no utility is registered for it.inheritedData(content, behavior), fromhelpers/inheritA behavior's data as
@components.inheritholds it, orundefinedwhen the expansion was not requested or no object provides the behavior.SETTINGS_BEHAVIOR, fromconstants'plonegovbr.socialmedia.settings'.
Settings#
Key |
Type |
Default |
What it does |
|---|---|---|---|
|
|
Not set |
The links |
Shadowed component#
The add-on shadows one Volto component.
Shadowed |
Why |
|---|---|
|
To read the social media settings from the behavior rather than from Plone's control panel. |
The shadow re-exports components/ComponentMetadataTags/ContentMetadataTags, which renders these tags.
Tag |
Content |
Rendered when |
|---|---|---|
|
|
Always |
|
|
Always |
|
|
Always |
|
|
|
|
|
|
|
|
|
|
|
Always |
|
The canonical address |
Always |
|
|
|
|
The |
Either image has a |
|
|
One of them is set |
|
|
Always |
The navigation root's title is added only when config.settings.siteTitleFormat.includeSiteTitle is on and that title differs from title.
The separator is config.settings.siteTitleFormat.titleAndSiteTitleSeparator, and - when that is not set.
Soft hyphens are removed from the title.
The component fetches @navroot for the current page, unless a navroot API expander already covers the path.
Types#
Exported by types.
Type |
Describes |
|---|---|
|
What a |
|
One target of a link: |
|
One entry of |
|
The fields of |
|
One entry of a Follow Us block's |
|
What a Follow Us block stores. |
The module also augments two @plone/types interfaces.
Interface |
Key added |
|---|---|
|
|
|
|
Styles#
The styles are in src/theme/_main.scss.
Volto collects each add-on's theme/_main.scss into the module addonsThemeCustomizationsMain, which Volto Light Theme imports.
Custom property |
Default |
Applies to |
|---|---|---|
|
|
The |
|
|
The |
|
|
The |
|
|
The |
|
|
The |
|
|
The transition of an animated icon on hover |
|
Not defined |
The |
Volto's Icon fills an SVG with currentColor when no color prop is given, so the icon's color is its fill.
FooterLinks sets --block-alignment to left on its container.