Skip to content

Commit

Permalink
feat: added new blocktextimage (#1520)
Browse files Browse the repository at this point in the history
  • Loading branch information
BaskarMitrah authored Jun 22, 2023
1 parent e635fb5 commit d197da7
Show file tree
Hide file tree
Showing 11 changed files with 600 additions and 329 deletions.
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Using a theme, all of your default configuration lives in an npm package.
- [Contents](#contents)
- [Getting started](#getting-started)
- [Using GitHub repository templates](#using-github-repository-templates)
- [Using the Adobe I/O CLI](#using-the-adobe-io-cli)
- [Using the Adobe theme I/O](#using-the-adobe-theme-io)
- [Developing with Adobe Theme I/O](#developing-with-adobe-theme-io)
- [Content structure](#content-structure)
- [Frontmatter](#frontmatter)
- [Edition keyword](#edition-keyword)
Expand All @@ -72,6 +73,7 @@ Using a theme, all of your default configuration lives in an npm package.
- [Global Navigation](#global-navigation)
- [Menus](#menus)
- [Home link](#home-link)
- [Table Image](#table-image)
- [Side Navigation](#side-navigation)
- [Variations](#variations)
- [Single-level side navigation](#single-level-side-navigation)
Expand All @@ -92,6 +94,7 @@ Using a theme, all of your default configuration lives in an npm package.
- [Deploy to Azure Storage Static Websites](#deploy-to-azure-storage-static-websites)
- [Writing Enhanced Markdown](#writing-enhanced-markdown)
- [Metadata with Front matter](#metadata-with-front-matter)
- [hideBreadcrumbNav: false](#hidebreadcrumbnav-false)
- [OpenAPI](#openapi)
- [JSDoc](#jsdoc)
- [MDX](#mdx)
Expand All @@ -108,6 +111,7 @@ Using a theme, all of your default configuration lives in an npm package.
- [Anatomy of an InlineAlert block](#anatomy-of-an-inlinealert-block)
- [Simple InlineAlert](#simple-inlinealert)
- [Richer InlineAlert](#richer-inlinealert)
- [Nested InlineAlert](#nested-inlinealert)
- [Media Block](#media-block)
- [Announcement Block](#announcement-block)
- [Summary Block](#summary-block)
Expand All @@ -118,7 +122,13 @@ Using a theme, all of your default configuration lives in an npm package.
- [Product Card](#product-card)
- [Product Card Grid](#product-card-grid)
- [Resource Card](#resource-card)
- [MiniResourceCard](#miniresourcecard)
- [Carousel](#carousel)
- [VideoCarousel](#videocarousel)
- [ImageTextBlock](#imageTextBlock)
- [TeaserBlock](#teaserblock)
- [Accordion](#accordion)
- [Accordion item](#accordion-item)
- [Edition](#edition)
- [Embedding markdown documents and filtering content](#embedding-markdown-documents-and-filtering-content)
- [Embedding local markdown files](#embedding-local-markdown-files)
Expand Down Expand Up @@ -2128,6 +2138,47 @@ Letter is an email newsletter tool that helps content creators, designers, and d
* [View docs](../guides)
```
### ImageTextBlock
ImageTextBlock is used to display two images, along with text, a heading, and buttons, arranged horizontally. This layout allows for a visually appealing presentation of the content within the modal.
![ImageTextBlock](docs/images/imagetext-block.png)
```
<ImageTextBlock slots="image,heading,text,buttons" repeat="2" bgColor="#f8f8f8" className="boxmodal" isCenter variantsTypePrimary='accent'/>
![Adobe Service](6_Image_Sales.jpg)
## Adobe Service
Service is the rent we pay for being. It is not something you do in your spare time
- [Learn more](https://adobe.io)
![Adobe InDesign](6_Image_Rental.jpg)
## Adobe InDesign
Adobe InDesign brings its new share for review features to life with Adobe.
- [Learn more](https://adobe.io)
```
Use `slots` to identify the markdown content:
- `image` (required)
- `heading` (optional)
- `text` (optional)
- `buttons`(optional)
Use `bgColor` to load the backgroundcolor.
Use `repeat` to define how many code sections are part. The limit for repeat is two.
Use `isCenter` to center the text.
Use `className` to customize the component **at your own risk.**
### TeaserBlock
Expand Down
Binary file added docs/images/imagetext-block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions example/src/pages/imageTextBlock/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<ImageTextBlock slots="image,heading,text,buttons" repeat="2" bgColor="#f8f8f8" className="boxmodal" isCenter variantsTypePrimary='accent'/>

![Adobe Service](6_Image_Sales.jpg)

## Adobe Service

Service is rent we pay for being. It's something you do in your spare time

- [Learn more](https://adobe.io)

![Adobe InDesign](6_Image_Rental.jpg)

## Adobe InDesign

Adobe InDesign brings its new share features to life with Adobe.

- [Learn more](https://adobe.io)
23 changes: 13 additions & 10 deletions example/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import VideoCarouselComp from './videoCarousel/videoCarousel.md'
import blackbg from "./teaser/black_power.jpg"
import TextBlockComp from "./textblock/textblock.md"
import MiniResource from "./miniresource_block/index.md"
import TextBlockImage from "./imageTextBlock/index.md"

<Hero slots="image, heading, text" background="rgb(64, 34, 138)" hideBreadcrumbNav={false}/>

Expand Down Expand Up @@ -164,6 +165,8 @@ Accordion item is to expand and collapse the content by clicking the icon. By de

<MiniResource />

<TextBlockImage />

## Inline Alerts {#Categories}

These are the five types of inline alerts you can use.
Expand Down Expand Up @@ -260,25 +263,25 @@ This is an example of `inline code` written with the standard markdown backticks

Some tables here for testing.

| | |
|-----------------|----------------------------|
| | |
| --------------- | -------------------------- |
| **Class name:** | `InstallSchema` |
| **Interface:** | [`InstallSchemaInterface`] |
| **Method:** | `install()` |

| |
|:----------------:|
| |
| :-------------: |
| **Class name:** |
| **Interface:** |
| **Method:** |
| **Method:** |

Here's a table with some column headers and bigger rows.

Element | Description
--- | ---
`name` | A fully-qualified component name, in the format `<vendor-name>/<component-name>`. All letters must be in lowercase. Use dashes in the `<component-name>` to separate words. Themes must use the format `<vendor-name>/theme-<area>-<theme-name>`.
`type` | For modules, this value must be set to `magento2-module`. Other possible types are `metapackage`, `magento2-theme`, and `magento2-language`.
`autoload` | Specify necessary information to be loaded, such as [registration.php](../build/component-registration.md). For more information, see [Autoloading](https://getcomposer.org/doc/01-basic-usage.md#autoloading) from Composer.
| Element | Description |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | A fully-qualified component name, in the format `<vendor-name>/<component-name>`. All letters must be in lowercase. Use dashes in the `<component-name>` to separate words. Themes must use the format `<vendor-name>/theme-<area>-<theme-name>`. |
| `type` | For modules, this value must be set to `magento2-module`. Other possible types are `metapackage`, `magento2-theme`, and `magento2-language`. |
| `autoload` | Specify necessary information to be loaded, such as [registration.php](../build/component-registration.md). For more information, see [Autoloading](https://getcomposer.org/doc/01-basic-usage.md#autoloading) from Composer. |

Inline Alert as a nested component

Expand Down
200 changes: 200 additions & 0 deletions packages/gatsby-theme-aio/src/components/ImageTextBlock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import React, { cloneElement } from "react";
import { css } from '@emotion/react';
import classNames from "classnames";
import { cloneChildren } from "../../utils";
import { HeroButtons } from "../Hero";
import PropTypes from "prop-types";

const setImageLoading = (child) => {
if (child?.props?.mdxType === 'img') {
return cloneElement(child, {
loading: 'eager'
});
}

return child;
};

const ModalImage = ({ image, styles }) =>
image
? cloneElement(image, {
children: cloneChildren(image.props.children, setImageLoading),
css: css`
display: flex;
align-items: center;
justify-content: center;
align-self:center;
height: 100%;
width: 500px;
margin-top: 0;
${styles}
.gatsby-resp-image-wrapper {
max-width: none !important;
width: 100% !important;
height: 100% !important;
}
.gatsby-resp-image-image {
object-fit: cover;
}
@media screen and (min-width:320px) and (max-width:1024px) {
width: 290px !important;
}
`
})
: null;

const Modal = ({
image,
heading,
text,
buttons,
isCenter,
variantsTypePrimary,
variantsTypeSecondary,
}) => {

return (
<div
css={css`
display : flex;
justify-content: center;
flex-direction:column;
`}
>
<ModalImage image={image} />
<div
css={css`
width: 95%;
margin: 4% auto;
display: flex;
flex-direction: column;
justify-content: center;
`}
>
<div
css={css`
&gt;span {
display: none !important;
}
&gt;hr {
display: none !important;
}
text-align:${isCenter ? "center" : "initial"} !important;
`}
>
{heading}
</div>
<div
css={css`
text-align:${isCenter ? "center" : "initial"}
`}
>
{text}
</div>
<div
css={css`
display : flex;
justify-content: ${isCenter ? "center" : "start"};
`}
>
{buttons &&
<HeroButtons
buttons={buttons}
variants={[variantsTypePrimary, variantsTypeSecondary]}
css={css`
margin-top: var(--spectrum-global-dimension-size-250);
`} />
}
</div>
</div>
</div>
)
}

const ImageTextBlock = ({
className,
bgColor = "white",
isCenter,
variantsTypePrimary = "accent",
variantsTypeSecondary = "secondary",
...props
}) => {
const propKeys = Object?.keys(props);
const blocks = propKeys.filter((key) => key.startsWith("image")).map((data, index) => {
return {
image: props[data],
heading: props[`heading${index}`],
text: props[`text${index}`],
buttons: props[`buttons${index}`]
};
});

return (
<section
css={css`
margin:auto;
padding : 4% 0;
background-color:${bgColor}
`}
className={classNames(className)}
>
<div
css={css`
display : flex;
justify-content:center;
gap:10%;
@media screen and (min-width:320px) and (max-width:767px) {
flex-direction:column !important;
}
`
}
>
{blocks.map((data, index) => {
return (
<div key={index} >
<Modal
image={data.image}
heading={data.heading}
text={data.text}
buttons={data.buttons}
isCenter={isCenter}
variantsTypePrimary={variantsTypePrimary}
variantsTypeSecondary={variantsTypeSecondary}
/>
</div>
);
})}
</div>
</section>
)
}

ImageTextBlock.propTypes = {
className: PropTypes.string,
bgColor: PropTypes.string,
isCenter: PropTypes.bool,
variantsTypePrimary: PropTypes.string,
variantsTypeSecondary: PropTypes.string,

};

export { ImageTextBlock }
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const InlineNestedAlert = ({ variant = 'info', header, iconPosition, ...props })

InlineNestedAlert.propTypes = {
variant: PropTypes.string,
header: PropTypes.element,
header: PropTypes.text,
text: PropTypes.element
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import { DCSummaryBlock } from '../DCSummaryBlock';
import { TeaserBlock } from "../TeaserBlock";
import { VideoCarousel } from '../VideoCarousel';
import { MiniResourceCard } from '../MiniResourceCard';
import { ImageTextBlock } from '../ImageTextBlock';

export const MDXBlocks = {
Hero,
DiscoverBlock,
Expand Down Expand Up @@ -80,5 +82,6 @@ export const MDXBlocks = {
AnchorButtonGroup,
DCSummaryBlock,
VideoCarousel,
MiniResourceCard
MiniResourceCard,
ImageTextBlock
};
Loading

0 comments on commit d197da7

Please sign in to comment.