Skip to content

Commit

Permalink
Merge branch 'main' into externallink
Browse files Browse the repository at this point in the history
  • Loading branch information
danalvrz authored Dec 17, 2024
2 parents dfe0ea8 + 241c08b commit 00bad6e
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

<!-- towncrier release notes start -->

## 6.0.0-alpha.9 (2024-12-17)

### Feature

- Added logos footer handlers for logo size and logos container size. Overall improvements for look and feel. @sneridagh [#451](https://github.com/kitconcept/volto-light-theme/pull/451)

### Bugfix

- Remove teaser styling tab inside grids since it's empty. @sneridagh [#449](https://github.com/kitconcept/volto-light-theme/pull/449)
- Remove the last dangling `aspect-ratio` handler from image block. @sneridagh [#450](https://github.com/kitconcept/volto-light-theme/pull/450)

## 6.0.0-alpha.8 (2024-12-13)

### Bugfix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kitconcept/volto-light-theme-dev",
"version": "6.0.0-alpha.8",
"version": "6.0.0-alpha.9",
"description": "Volto Light Theme by kitconcept",
"main": "src/index.js",
"types": "src/types/index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions packages/volto-light-theme/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

<!-- towncrier release notes start -->

## 6.0.0-alpha.9 (2024-12-17)

### Feature

- Added logos footer handlers for logo size and logos container size. Overall improvements for look and feel. @sneridagh [#451](https://github.com/kitconcept/volto-light-theme/pull/451)

### Bugfix

- Remove teaser styling tab inside grids since it's empty. @sneridagh [#449](https://github.com/kitconcept/volto-light-theme/pull/449)
- Remove the last dangling `aspect-ratio` handler from image block. @sneridagh [#450](https://github.com/kitconcept/volto-light-theme/pull/450)

## 6.0.0-alpha.8 (2024-12-13)

### Bugfix
Expand Down
1 change: 0 additions & 1 deletion packages/volto-light-theme/news/449.bugfix

This file was deleted.

1 change: 0 additions & 1 deletion packages/volto-light-theme/news/450.bugfix

This file was deleted.

2 changes: 1 addition & 1 deletion packages/volto-light-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kitconcept/volto-light-theme",
"version": "6.0.0-alpha.8",
"version": "6.0.0-alpha.9",
"description": "Volto Light Theme by kitconcept",
"main": "src/index.ts",
"types": "src/types/index.d.ts",
Expand Down
27 changes: 23 additions & 4 deletions packages/volto-light-theme/src/components/Footer/FooterLogos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
import ConditionalLink from '@plone/volto/components/manage/ConditionalLink/ConditionalLink';
import { useSelector } from 'react-redux';
import { Container } from '@plone/components';
import cx from 'classnames';

type FormState = {
content: {
data: Content;
};
form: {
global: Content;
};
navroot: {
data: {
navroot: Content;
Expand All @@ -20,11 +24,22 @@ const FooterLogos = () => {
const navroot = useSelector<FormState, Content>(
(state) => state.navroot.data.navroot,
);
const logos = navroot?.footer_logos;
const formState = useSelector<FormState, Content>(
(state) => state.form.global,
);
const logos = formState?.footer_logos || navroot?.footer_logos;
const logosSize = formState?.footer_logos_size || navroot?.footer_logos_size;
const footer_logos_container_width =
formState?.footer_logos_container_width ||
navroot?.footer_logos_container_width;

return (
<Container layout>
<ul className="footer-logos">
<Container className={cx({ [footer_logos_container_width]: 1 })}>
<ul
className={cx('footer-logos', {
[logosSize]: logosSize,
})}
>
{!isEmpty(logos?.blocks)
? logos.blocks_layout.items.map((itemId) => {
const logo = logos.blocks[itemId];
Expand All @@ -41,14 +56,18 @@ const FooterLogos = () => {
src: '',
srcAlt: '',
};
if (logo?.href) {
if (logo?.href?.length > 0) {
logoInfo.hrefTitle = logo.href[0]['title'];
logoInfo.href = flattenToAppURL(logo.href[0]['@id']);
}
if (logo?.logo && logo.logo[0]?.image_scales) {
logoInfo.logoHref = logo.logo[0]['@id'];
logoInfo.srcAlt = logo['alt'];
logoInfo.src = `${flattenToAppURL(logoInfo.logoHref)}/${logo.logo[0].image_scales[logo.logo[0].image_field][0].download}`;
} else if (logo?.logo) {
logoInfo.logoHref = logo.logo[0]['@id'];
logoInfo.srcAlt = logo['alt'];
logoInfo.src = `${flattenToAppURL(logoInfo.logoHref)}/@@images/image`;
}

if (!logoInfo.src) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@ const ButtonsWidget = (props: ButtonsWidgetProps) => {
key={action.name}
aria-label={actionsInfoMap[action.name][1]}
onPress={() => onChange(id, action.style || action.name)}
className={isEqual(value, action.style) ? 'active' : null}
className={
isEqual(value, action.style || action.name) ? 'active' : null
}
isDisabled={disabled || isDisabled}
>
<Icon
name={actionsInfoMap[action.name][0]}
title={actionsInfoMap[action.name][1] || action.name}
size="24px"
/>
{typeof actionsInfoMap[action.name][0] === 'string' ? (
<div className="image-sizes-text">
{actionsInfoMap[action.name][0]}
</div>
) : (
<Icon
name={actionsInfoMap[action.name][0]}
title={actionsInfoMap[action.name][1] || action.name}
size="24px"
/>
)}
</Button>
))}
</div>
Expand Down
68 changes: 68 additions & 0 deletions packages/volto-light-theme/src/components/Widgets/SizeWidget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { defineMessages, useIntl } from 'react-intl';
import ButtonsWidget, { type ButtonsWidgetProps } from './ButtonsWidget';
import type { IntlShape } from 'react-intl';

const messages = defineMessages({
s: {
id: 'Small',
defaultMessage: 'Small',
},
m: {
id: 'Medium',
defaultMessage: 'Medium',
},
l: {
id: 'Large',
defaultMessage: 'Large',
},
});

export const defaultActionsInfo = ({ intl }: { intl: IntlShape }) => ({
s: ['S', intl.formatMessage(messages.s)],
m: ['M', intl.formatMessage(messages.m)],
l: ['L', intl.formatMessage(messages.l)],
});

const DEFAULT_ACTIONS = [
{
name: 's',
label: 'Small',
},
{
name: 'm',
label: 'Medium',
},
{
name: 'l',
label: 'Large',
},
];

const SizeWidget = (props: ButtonsWidgetProps) => {
const intl = useIntl();

const { actions = DEFAULT_ACTIONS, actionsInfoMap, filterActions } = props;
let filteredActions;
if (filterActions) {
filteredActions = actions.filter((action) =>
filterActions.includes(action.name),
);
} else {
filteredActions = actions;
}

const actionsInfo = {
...defaultActionsInfo({ intl }),
...actionsInfoMap,
};

return (
<ButtonsWidget
{...props}
actions={filteredActions}
actionsInfoMap={actionsInfo}
/>
);
};

export default SizeWidget;
3 changes: 3 additions & 0 deletions packages/volto-light-theme/src/config/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import BlockAlignmentWidget from '../components/Widgets/BlockAlignmentWidget';
import ColorPickerWidget from '../components/Widgets/ColorPickerWidget';
import FooterLogosWidget from '../components/Widgets/FooterLogosWidget';
import FooterLinksWidget from '../components/Widgets/FooterLinksWidget';
import SizeWidget from '../components/Widgets/SizeWidget';

declare module '@plone/types' {
export interface WidgetsConfigByWidget {
Expand All @@ -15,6 +16,7 @@ declare module '@plone/types' {
themingColorPicker: typeof ThemingColorPicker;
footerLogos: typeof FooterLogosWidget;
footerLinks: typeof FooterLinksWidget;
sizeWidget: React.ComponentType<any>;
}
}

Expand All @@ -26,6 +28,7 @@ export default function install(config: ConfigType) {
config.widgets.widget.themingColorPicker = ThemingColorPicker;
config.widgets.widget.footerLogos = FooterLogosWidget;
config.widgets.widget.footerLinks = FooterLinksWidget;
config.widgets.widget.sizeWidget = SizeWidget;

return config;
}
2 changes: 2 additions & 0 deletions packages/volto-light-theme/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ defineMessages({
declare module '@plone/types' {
export interface Content {
footer_logos: BlocksData;
footer_logos_container_width: string;
footer_logos_size: string;
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/volto-light-theme/src/theme/_container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
@include layout-container-width;
}

&.default {
@include default-container-width;
}

&.narrow {
@include narrow-container-width;
}
Expand Down
20 changes: 9 additions & 11 deletions packages/volto-light-theme/src/theme/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@

ul.footer-logos {
display: grid;
align-items: center;
justify-content: center;
padding: $pre-footer-vertical-spacing 0;
padding-left: 0;
margin-top: 0;
margin-bottom: $spacing-medium;
gap: 20px;
grid-template-columns: repeat(3, 1fr);
gap: 60px 20px;
grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
list-style: none;

img {
max-width: 100%;
&.l img {
max-width: min(100%, 240px);
max-height: 165px;
}

li.item:nth-child(3n + 1) {
/* Targets 1st, 4th, 7th, etc. */
justify-self: start;
}
li.item:nth-child(3n + 3) {
/* Targets 3rd, 6th, 9th, etc. */
justify-self: end;
&.s img {
max-width: min(100%, 175px);
max-height: 120px;
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/volto-light-theme/src/theme/_widgets.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#sidebar-properties {
#sidebar-properties,
#sidebar-metadata {
.field.widget {
.buttons {
display: flex;
Expand Down

0 comments on commit 00bad6e

Please sign in to comment.