Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
jnptk committed Jan 12, 2024
1 parent d1fafd5 commit eacc767
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/components/Body.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DefaultSliderBody from "./DefaultBody";
import DefaultSliderBody from './DefaultBody';

const SliderBody = (props) => {
const { variation } = props;
Expand Down
10 changes: 5 additions & 5 deletions src/components/Data.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";
import { useIntl } from "react-intl";
import { BlockDataForm } from "@plone/volto/components";
import { SliderSchema } from "./schema";
import React from 'react';
import { useIntl } from 'react-intl';
import { BlockDataForm } from '@plone/volto/components';
import { SliderSchema } from './schema';

const SliderData = (props) => {
const { block, blocksConfig, data, onChangeBlock } = props;
const intl = useIntl();
const schema = SliderSchema({ ...props, intl });

const dataAdapter = blocksConfig[data["@type"]].dataAdapter;
const dataAdapter = blocksConfig[data['@type']].dataAdapter;

return (
<BlockDataForm
Expand Down
14 changes: 7 additions & 7 deletions src/components/DefaultBody.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from "react";
import cx from "classnames";
import config from "@plone/volto/registry";
import React from 'react';
import cx from 'classnames';
import config from '@plone/volto/registry';

const DefaultImage = (props) => <img {...props} alt={props.alt || ""} />;
const DefaultImage = (props) => <img {...props} alt={props.alt || ''} />;

const SliderBody = ({ data, isActive }) => {
const image = data.image?.[0];

const Image = config.getComponent("Image").component || DefaultImage;
const Image = config.getComponent('Image').component || DefaultImage;

return (
<div
className={cx("grid-teaser-item top", {
className={cx('grid-teaser-item top', {
// "empty-slide": !href && isEditMode,
"slide-visible": isActive,
'slide-visible': isActive,
})}
>
<div className="teaser-item top">
Expand Down
20 changes: 10 additions & 10 deletions src/components/DotsAndArrows.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Icon } from "@plone/volto/components";
import { useIntl, defineMessages } from "react-intl";
import rightArrowSVG from "@plone/volto/icons/right-key.svg";
import leftArrowSVG from "@plone/volto/icons/left-key.svg";
import { Icon } from '@plone/volto/components';
import { useIntl, defineMessages } from 'react-intl';
import rightArrowSVG from '@plone/volto/icons/right-key.svg';
import leftArrowSVG from '@plone/volto/icons/left-key.svg';

const messages = defineMessages({
previousButton: {
id: "Previous slide",
defaultMessage: "Previous slide",
id: 'Previous slide',
defaultMessage: 'Previous slide',
},
nextButton: {
id: "Next slide",
defaultMessage: "Next slide",
id: 'Next slide',
defaultMessage: 'Next slide',
},
goToSlide: {
id: "Go to slide",
defaultMessage: "Go to slide",
id: 'Go to slide',
defaultMessage: 'Go to slide',
},
});

Expand Down
10 changes: 5 additions & 5 deletions src/components/Edit.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import { withBlockExtensions } from "@plone/volto/helpers";
import View from "./View";
import { SidebarPortal } from "@plone/volto/components";
import Sidebar from "./Sidebar";
import React from 'react';
import { withBlockExtensions } from '@plone/volto/helpers';
import View from './View';
import { SidebarPortal } from '@plone/volto/components';
import Sidebar from './Sidebar';

const SliderEdit = (props) => {
const { onChangeBlock, block, selected, data } = props;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Segment } from "semantic-ui-react";
import React from 'react';
import { Segment } from 'semantic-ui-react';

import Data from "./Data";
import Data from './Data';

const SliderSidebar = (props) => {
return (
Expand Down
32 changes: 16 additions & 16 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useCallback, useEffect, useState } from "react";
import useEmblaCarousel from "embla-carousel-react";
import cx from "classnames";
import Body from "./Body";
import { withBlockExtensions } from "@plone/volto/helpers";
import { DotButton, NextButton, PrevButton } from "./DotsAndArrows";
import React, { useCallback, useEffect, useState } from 'react';
import useEmblaCarousel from 'embla-carousel-react';
import cx from 'classnames';
import Body from './Body';
import { withBlockExtensions } from '@plone/volto/helpers';
import { DotButton, NextButton, PrevButton } from './DotsAndArrows';

const SliderView = (props) => {
const {
Expand Down Expand Up @@ -45,7 +45,7 @@ const SliderView = (props) => {
setSlideIndex && setSlideIndex(index);
}
},
[emblaApi, setSlideIndex]
[emblaApi, setSlideIndex],
);

const onInit = useCallback((emblaApi) => {
Expand All @@ -63,9 +63,9 @@ const SliderView = (props) => {

onInit(emblaApi);
onSelect(emblaApi);
emblaApi.on("reInit", onInit);
emblaApi.on("reInit", onSelect);
emblaApi.on("select", onSelect);
emblaApi.on('reInit', onInit);
emblaApi.on('reInit', onSelect);
emblaApi.on('select', onSelect);
}, [emblaApi, onInit, onSelect]);

useEffect(() => {
Expand All @@ -84,8 +84,8 @@ const SliderView = (props) => {
return (
<>
<div
className={cx("block slider", className)}
style={{ "--slider-container-width": `${sliderContainerWidth}px` }}
className={cx('block slider', className)}
style={{ '--slider-container-width': `${sliderContainerWidth}px` }}
>
{data.slides?.length > 0 && (
<>
Expand All @@ -101,10 +101,10 @@ const SliderView = (props) => {
{data.slides &&
data.slides.map((item, index) => {
return (
<div key={item["@id"]} className="slider-slide">
<div key={item['@id']} className="slider-slide">
<Body
{...props}
key={item["@id"]}
key={item['@id']}
data={item}
isEditMode={isEditMode}
dataBlock={data}
Expand All @@ -127,8 +127,8 @@ const SliderView = (props) => {
key={index}
index={index}
onClick={() => scrollTo(index)}
className={"slider-dot".concat(
index === selectedIndex ? " slider-dot--selected" : ""
className={'slider-dot'.concat(
index === selectedIndex ? ' slider-dot--selected' : '',
)}
/>
))}
Expand Down
8 changes: 4 additions & 4 deletions src/components/adapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { difference } from "@plone/volto/helpers";
import { replaceItemOfArray } from "@plone/volto/helpers";
import { compact } from "lodash";
import { difference } from '@plone/volto/helpers';
import { replaceItemOfArray } from '@plone/volto/helpers';
import { compact } from 'lodash';

export const SliderBlockDataAdapter = ({
block,
Expand All @@ -14,7 +14,7 @@ export const SliderBlockDataAdapter = ({
[id]: value,
};

if (id === "slides" && data[id]) {
if (id === 'slides' && data[id]) {
const diff = difference(value, data[id]);
// If we are moving two items in the array, the changeset is > 1
// then we do not do any sync
Expand Down
68 changes: 34 additions & 34 deletions src/components/schema.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { defineMessages } from "react-intl";
import config from "@plone/volto/registry";
import { mergeSchemas } from "../helpers";
import { v4 as uuid } from "uuid";
import { defineMessages } from 'react-intl';
import config from '@plone/volto/registry';
import { mergeSchemas } from '../helpers';
import { v4 as uuid } from 'uuid';

const messages = defineMessages({
Slider: {
id: "Slider",
defaultMessage: "Slider",
id: 'Slider',
defaultMessage: 'Slider',
},
testimonial: {
id: "Testimonial",
defaultMessage: "Testimonial",
id: 'Testimonial',
defaultMessage: 'Testimonial',
},
image: {
id: "Image",
defaultMessage: "Image",
id: 'Image',
defaultMessage: 'Image',
},
name: {
id: "Name",
defaultMessage: "Name",
id: 'Name',
defaultMessage: 'Name',
},
additionalData: {
id: "Additional data",
defaultMessage: "Additional data",
id: 'Additional data',
defaultMessage: 'Additional data',
},
item: {
id: "Item",
defaultMessage: "Item",
id: 'Item',
defaultMessage: 'Item',
},
items: {
id: "Items",
defaultMessage: "Items",
id: 'Items',
defaultMessage: 'Items',
},
addItem: {
id: "Add item",
defaultMessage: "Add item",
id: 'Add item',
defaultMessage: 'Add item',
},
});

Expand All @@ -45,21 +45,21 @@ export const itemSchema = (props) =>
addMessage: props.intl.formatMessage(messages.addItem),
fieldsets: [
{
id: "default",
title: "Default",
fields: ["testimonial", "image", "name", "additionalData"],
id: 'default',
title: 'Default',
fields: ['testimonial', 'image', 'name', 'additionalData'],
},
],

properties: {
testimonial: {
title: props.intl.formatMessage(messages.testimonial),
widget: "textarea",
widget: 'textarea',
},
image: {
title: props.intl.formatMessage(messages.image),
widget: "object_browser",
mode: "image",
widget: 'object_browser',
mode: 'image',
allowExternals: true,
},
name: {
Expand All @@ -71,32 +71,32 @@ export const itemSchema = (props) =>
},
required: [],
},
config.blocks.blocksConfig.slider.extensions?.slideSchema || {}
config.blocks.blocksConfig.slider.extensions?.slideSchema || {},
);

export const SliderSchema = (props) =>
mergeSchemas(
{
title: props.intl.formatMessage(messages.Slider),
block: "slider",
block: 'slider',
fieldsets: [
{
id: "default",
title: "Default",
fields: ["slides"],
id: 'default',
title: 'Default',
fields: ['slides'],
},
],
properties: {
slides: {
widget: "object_list",
widget: 'object_list',
title: props.intl.formatMessage(messages.items),
schema: itemSchema(props),
activeObject: props.activeObject,
setActiveObject: props.setActiveObject,
default: [{ "@id": uuid() }],
default: [{ '@id': uuid() }],
},
},
required: [],
},
config.blocks.blocksConfig.slider.extensions?.blockSchema || {}
config.blocks.blocksConfig.slider.extensions?.blockSchema || {},
);
4 changes: 2 additions & 2 deletions src/helpers/Schema/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @module helpers/schema/schema
*/

import merge from "deepmerge";
import { findIndex, map } from "lodash";
import merge from 'deepmerge';
import { findIndex, map } from 'lodash';

/**
* Merge schemas
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { mergeSchemas } from "./Schema/Schema";
import { mergeSchemas } from './Schema/Schema';

export { mergeSchemas };
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Edit from "./components/Edit";
import View from "./components/View";
import sliderSVG from "@plone/volto/icons/slider.svg";
import { SliderBlockDataAdapter } from "./components/adapter";
import Edit from './components/Edit';
import View from './components/View';
import sliderSVG from '@plone/volto/icons/slider.svg';
import { SliderBlockDataAdapter } from './components/adapter';

import "./theme/main.less";
import './theme/main.less';

const applyConfig = (config) => {
config.blocks.blocksConfig.slider = {
id: "slider",
title: "Slider",
group: "common",
id: 'slider',
title: 'Slider',
group: 'common',
icon: sliderSVG,
view: View,
edit: Edit,
Expand Down
Loading

0 comments on commit eacc767

Please sign in to comment.