Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: added new component to list the ordered, unordered list #1533

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ 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)
- [](#)
- [description: This is the guides overview page of Adobe Analytics](#description-this-is-the-guides-overview-page-of-adobe-analytics)
- [](#-1)
- [](#-2)
- [hideBreadcrumbNav: false](#hidebreadcrumbnav-false)
- [OpenAPI](#openapi)
- [openAPISpec: https://raw.githubusercontent.com/AdobeDocs/analytics-2.0-apis/master/docs/swagger.json](#openapispec-httpsrawgithubusercontentcomadobedocsanalytics-20-apismasterdocsswaggerjson)
- [JSDoc](#jsdoc)
- [jsDoc: true](#jsdoc-true)
- [MDX](#mdx)
- [Modular Content System](#modular-content-system)
- [JSX Blocks](#jsx-blocks)
Expand Down Expand Up @@ -125,10 +131,11 @@ Using a theme, all of your default configuration lives in an npm package.
- [MiniResourceCard](#miniresourcecard)
- [Carousel](#carousel)
- [VideoCarousel](#videocarousel)
- [ImageTextBlock](#imageTextBlock)
- [ImageTextBlock](#imagetextblock)
- [TeaserBlock](#teaserblock)
- [Accordion](#accordion)
- [Accordion item](#accordion-item)
- [ListBlock](#listblock)
- [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 @@ -2092,7 +2099,7 @@ Use `repeat` to define how many code sections are part of the carousel.

VideoCarousel is used to show the information along with videos and buttons.

![Carousel](docs/images/videoCarousel.png)
![Carousel](docs/images/video-carousel.png)

Use `slots` to identify the markdown content:

Expand Down Expand Up @@ -2265,6 +2272,47 @@ AccordionItem default expand
</Accordion>

```
### ListBlock

The `ListBlock` component showcases a two-column layout with alternating left and right content.

![listblock](docs/images/list-block.png)

```
<ListBlock slots="text1, text2" repeat="4" iconColor="#2ac3a2" icon="checkmark" variant="fullWidth" />

500 free Document Transactions per month

Volume and multi-product discounts

Access to all 15+ PDF Services including PDF Extract, PDF Accessibility Auto-Tag API, and Document Generation

Access to all 15+ PDF Services including PDF Extract, PDF Accessibility Auto-Tag API, and Document Generation

Easy to sign up and create credentials in minutes

Technical Support included (different tiers available)

No credit card or commitment required

Scalable for high volume needs.

```
Use `slots` to identify the markdown content:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain further on how each child will be rendered? When I look at a list, I thought the children are rendering as a list and first 4 items are on the left and last 4 items are on the right. Instead, right now it's rendering from left and right with 1,3,5,7 on left and 2,4,6,8 on right. We could have this behaviour but please explain better so the user understand how they would should put their content.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some content information on the README


- `text1`(required) is placed in left side.
- `text2`(required) is placed in right side.

Use `repeat`(required) to define how many code sections are part.

Use `iconColor` to define the marker color. The preset is black.

Use `icon` used to indicate individual items or elements within the list. By default it is in `checkmark`. Values are `checkmark,disc, number`.

Use `variant` to specify full width or half width values are `fullWidth,halfWidth`.

Text1 will align the text on the leftside list i.e (1,3,5,...)
Text2 will align the text on right side i.e (2,4,6...)

### Edition

Expand Down
Binary file added docs/images/list-block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
4 changes: 4 additions & 0 deletions example/src/pages/imageTextBlock/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Text block with the image

This is an example for image on the text block

<ImageTextBlock slots="image,heading,text,buttons" repeat="2" bgColor="#f8f8f8" className="boxmodal" isCenter variantsTypePrimary='accent'/>

![Adobe Service](6_Image_Sales.jpg)
Expand Down
3 changes: 3 additions & 0 deletions example/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ 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"
import ListComp from "./listblock/index.md"

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

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

<TextBlockImage />

<ListComp />

## Inline Alerts {#Categories}

These are the five types of inline alerts you can use.
Expand Down
21 changes: 21 additions & 0 deletions example/src/pages/listblock/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## List Block

This an exmaple of showing list

<ListBlock slots="text1, text2" repeat="4" iconColor="#2ac3a2" icon="checkmark" variant="fullWidth" />

500 free Document Transactions per month

Volume and multi-product discounts

Access to all 15+ PDF Services including PDF Extract, PDF Accessibility Auto-Tag API, and Document Generation

Access to all 15+ PDF Services including PDF Extract, PDF Accessibility Auto-Tag API, and Document Generation

Easy to sign up and create credentials in minutes

Technical Support included (different tiers available)

No credit card or commitment required

Scalable for high volume needs.
125 changes: 125 additions & 0 deletions packages/gatsby-theme-aio/src/components/ListBlock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* 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 from "react"
import { css } from '@emotion/react';
import PropTypes from "prop-types";
import classNames from "classnames";

const commonCSS = `
width: 45%;
margin: 0 !important;

@media screen and (min-width:320px) and (max-width:767px) {
width : 90% !important;
}`

const List = ({ icon, iconColor, listItem, content }) => {

const bulletIcons = icon ?? "checkmark";

return (
<ul css={css` ${commonCSS}`}>
{listItem?.map((data, index) => {
const shouldHideBullet = bulletIcons === "checkmark" || (content === "right" && data?.text1 === undefined) || (content === "left" && data?.text2 === undefined);
return (
<li
key={index}
css={css`
list-style: ${shouldHideBullet ? "none " : bulletIcons};
font-size: 1.5em;
position: ${bulletIcons === "checkmark" && "relative"};
padding-left: ${bulletIcons === "checkmark" && "1.5em"};
&::marker {
color: ${iconColor};
}

& > p{
margin: var(--spectrum-global-dimension-size-150) 0 !important;
}

${bulletIcons === "checkmark" &&
`&:before {
content: "\u2713";
position: absolute;
left:0;
top: 0;
color: ${iconColor};
}`
}
`}>
{content === "right" ? data?.text1 : data?.text2}
</li>
)
})} </ul>
)
}

const ListBlock = ({
className,
icon,
variant = "halfWidth",
iconColor = "black",
repeat,
...props
}) => {

const propKeys = Object?.keys(props);
const listItem = propKeys.filter((key) => key.startsWith("text2")).map((data, index) => {
return {
text1: props[data],
text2: repeat === "1" || repeat === undefined ? props["text1"] : props[`text1${index}`],
};
});

return (
<section
className={classNames(className)}
css={css`
margin:auto;
padding : 4% 0;
width : ${variant === "halfWidth" ? "60%" : "100%"};
`}
>
<div>
<div
css={css`
display : flex;
justify-content: space-between;
text-align : left;

@media screen and (min-width:320px) and (max-width:767px) {
flex-direction:column;
}

`}
>
<List listItem={listItem} iconColor={iconColor} icon={icon} content="left" />

<div css={css`border-right: 1px solid var(--spectrum-global-color-gray-300)`}></div>

<List listItem={listItem} iconColor={iconColor} icon={icon} content="right" />

</div>
</div>
</section>
)
}

ListBlock.propTypes = {
className: PropTypes.string,
icon: PropTypes.string,
iconColor: PropTypes.string,
variant: PropTypes.string,
};

export { ListBlock }
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { TeaserBlock } from "../TeaserBlock";
import { VideoCarousel } from '../VideoCarousel';
import { MiniResourceCard } from '../MiniResourceCard';
import { ImageTextBlock } from '../ImageTextBlock';
import { ListBlock } from '../ListBlock';

export const MDXBlocks = {
Hero,
Expand Down Expand Up @@ -83,5 +84,6 @@ export const MDXBlocks = {
DCSummaryBlock,
VideoCarousel,
MiniResourceCard,
ImageTextBlock
ImageTextBlock,
ListBlock
};