From de68bf8cc100b0695509d435aedabd02767bfa68 Mon Sep 17 00:00:00 2001 From: Roger Leite Lucena Date: Tue, 16 Apr 2019 19:48:34 -0300 Subject: [PATCH 1/3] Add "defineMessages" for editor messages --- react/Carousel.tsx | 106 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 89 insertions(+), 17 deletions(-) diff --git a/react/Carousel.tsx b/react/Carousel.tsx index 3344e3f..fae334e 100644 --- a/react/Carousel.tsx +++ b/react/Carousel.tsx @@ -1,6 +1,7 @@ import classnames from 'classnames' import PropTypes from 'prop-types' import React, { Component } from 'react' +import { defineMessages } from 'react-intl' import { Dots, Slide, Slider, SliderContainer } from 'vtex.slider' import { Container } from 'vtex.store-components' import { IconCaret } from 'vtex.store-icons' @@ -38,6 +39,77 @@ interface ArrowContainerProps { children: React.ReactNode } +const editorMessages = defineMessages({ + CarouselTitle: { + id: 'editor.carousel.title', + defaultMessage: '' + }, + CarouselDescription: { + id: 'editor.carousel.description', + defaultMessage: '' + }, + CarouselShowDotsTitle: { + id: 'editor.carousel.showDots.title', + defaultMessage: '' + }, + CarouselShowArrowsTitle: { + id: 'editor.carousel.showArrows.title', + defaultMessage: '' + }, + CarouselHeightTitle: { + id: 'editor.carousel.height.title', + defaultMessage: '' + }, + CarouselAutoplayTitle: { + id: 'editor.carousel.autoplay.title', + defaultMessage: '' + }, + CarouselAutoplaySpeedTitle: { + id: 'editor.carousel.autoplaySpeed.title', + defaultMessage: '' + }, + CarouselBannerLinkPageTitle: { + id: 'editor.carousel.bannerLink.page.title', + defaultMessage: '' + }, + CarouselBannerLinkParamsTitle: { + id: 'editor.carousel.bannerLink.params.title', + defaultMessage: '' + }, + CarouselBannerLinkParamsDescription: { + id: 'editor.carousel.bannerLink.params.description', + defaultMessage: '' + }, + CarouselBannerLinkUrlTitle: { + id: 'editor.carousel.bannerLink.url.title', + defaultMessage: '' + }, + CarouselBannersTitle: { + id: 'editor.carousel.banners.title', + defaultMessage: '' + }, + CarouselBannerTitle: { + id: 'editor.carousel.banner.title', + defaultMessage: '' + }, + CarouselBannerDescriptionTitle: { + id: 'editor.carousel.banner.description.title', + defaultMessage: '' + }, + CarouselBannerExternalRouteTitle: { + id: 'editor.carousel.banner.externalRoute.title', + defaultMessage: '' + }, + CarouselBannerImageTitle: { + id: 'editor.carousel.banner.image.title', + defaultMessage: '' + }, + CarouselBannerMobileImageTitle: { + id: 'editor.carousel.banner.mobileImage.title', + defaultMessage: '' + }, +}) + /** * Carousel component. Shows a serie of banners. */ @@ -101,13 +173,13 @@ export default class Carousel extends Component { page: { enum: GLOBAL_PAGES, isLayout: false, - title: 'editor.carousel.bannerLink.page.title', + title: editorMessages.CarouselBannerLinkPageTitle.id, type: 'string', }, params: { - description: 'editor.carousel.bannerLink.params.description', + description: editorMessages.CarouselBannerLinkParamsDescription.id, isLayout: false, - title: 'editor.carousel.bannerLink.params.title', + title: editorMessages.CarouselBannerLinkParamsTitle.id, type: 'string', }, } @@ -115,19 +187,19 @@ export default class Carousel extends Component { const externalRouteSchema = { url: { isLayout: false, - title: 'editor.carousel.bannerLink.url.title', + title: editorMessages.CarouselBannerLinkUrlTitle.id, type: 'string', }, } return { - description: 'editor.carousel.description', + description: editorMessages.CarouselDescription.id, properties: { // tslint:disable-line autoplay: { default: true, isLayout: true, - title: 'editor.carousel.autoplay.title', + title: editorMessages.CarouselAutoplayTitle.id, type: 'boolean', }, autoplaySpeed: autoplay @@ -135,7 +207,7 @@ export default class Carousel extends Component { default: 5, enum: [4, 5, 6], isLayout: true, - title: 'editor.carousel.autoplaySpeed.title', + title: editorMessages.CarouselAutoplaySpeedTitle.id, type: 'number', widget: { 'ui:options': { @@ -152,20 +224,20 @@ export default class Carousel extends Component { // tslint:disable-line description: { default: '', - title: 'editor.carousel.banner.description.title', + title: editorMessages.CarouselBannerDescriptionTitle.id, type: 'string', }, externalRoute: { default: false, isLayout: false, - title: 'editor.carousel.banner.externalRoute.title', + title: editorMessages.CarouselBannerExternalRouteTitle.id, type: 'boolean', }, ...externalRouteSchema, ...internalRouteSchema, image: { default: '', - title: 'editor.carousel.banner.image.title', + title: editorMessages.CarouselBannerImageTitle.id, type: 'string', widget: { 'ui:widget': 'image-uploader', @@ -173,41 +245,41 @@ export default class Carousel extends Component { }, mobileImage: { default: '', - title: 'editor.carousel.banner.mobileImage.title', + title: editorMessages.CarouselBannerMobileImageTitle.id, type: 'string', widget: { 'ui:widget': 'image-uploader', }, }, }, - title: 'editor.carousel.banner.title', + title: editorMessages.CarouselBannerTitle.id, type: 'object', }, minItems: 1, - title: 'editor.carousel.banners.title', + title: editorMessages.CarouselBannersTitle.id, type: 'array', }, height: { default: 420, enum: [420, 440], isLayout: true, - title: 'editor.carousel.height.title', + title: editorMessages.CarouselHeightTitle.id, type: 'number', }, showArrows: { default: true, isLayout: true, - title: 'editor.carousel.showArrows.title', + title: editorMessages.CarouselShowArrowsTitle.id, type: 'boolean', }, showDots: { default: true, isLayout: true, - title: 'editor.carousel.showDots.title', + title: editorMessages.CarouselShowDotsTitle.id, type: 'boolean', }, }, - title: 'editor.carousel.title', + title: editorMessages.CarouselTitle.id, type: 'object', } } From 5f08244697ab690f98e68cee36fa67ff78e594fa Mon Sep 17 00:00:00 2001 From: Roger Leite Lucena Date: Tue, 16 Apr 2019 22:08:05 -0300 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94e8d5d..eb34937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Add `defineMessages` for all the messages (only editor messages in this project). ## [2.8.0] - 2019-03-25 ### Changed From ccd7413282e7c68a26955b35068db46354257a0d Mon Sep 17 00:00:00 2001 From: Roger Leite Lucena Date: Wed, 17 Apr 2019 13:45:12 -0300 Subject: [PATCH 3/3] Add react-intl to dev dependencies --- react/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/react/package.json b/react/package.json index c046df1..bfd4d21 100644 --- a/react/package.json +++ b/react/package.json @@ -26,6 +26,7 @@ "coveralls": "^3.0.3", "react": "^16.3.1", "react-dom": "^16.3.1", + "react-intl": "^2.8.0", "tslint": "^5.12.1", "tslint-config-vtex": "^2.1.0", "tslint-eslint-rules": "^5.4.0"