This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
(CEM-2514) MenuItemCard Component #383
Open
mfnisbetLU
wants to merge
15
commits into
cheapreats:master
Choose a base branch
from
mfnisbetLU:CEM-2514
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1a75865
Initial Commit
mfnisbetLU 08383b9
(CEM-2514) Menu Item Card Initial Commit
mfnisbetLU 64ee9f9
(CEM-2514) Soldout state + component position fixes
mfnisbetLU db04009
Changed default, added multiple stories for state testing
mfnisbetLU 74a4b8c
Fixed children arguments, added rounding edge case, increased item te…
mfnisbetLU 5f5ffc2
Merge branch 'master' into CEM-2514
mfnisbetLU 6968e20
Delete LimitedTimeBanner.stories.tsx
mfnisbetLU 92fb926
Delete LimitedTimeBanner.tsx
mfnisbetLU 2d4a1ac
Delete LoyaltyPoints.stories.tsx
mfnisbetLU 8cc63c9
Delete SaleTag.stories.tsx
mfnisbetLU 0ac735a
Delete LoyaltyPoints.tsx
mfnisbetLU 276f6d8
Delete SaleTag.tsx
mfnisbetLU b9d59e3
Revised draft of Menu Item Card using variable names from related com…
mfnisbetLU 79f213e
CEM-2514 Revised draft
mfnisbetLU 0b9a668
Merge branch 'CEM-2514' of https://github.com/mfnisbetLU/react-ui-lib…
mfnisbetLU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Containers/LimitedTimeBanner/LimitedTimeBanner.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { LimitedTimeBanner,LimitedTimeBannerProps} from '../../index'; | ||
import { createStoryTitle} from '../../Constants'; | ||
|
||
export default { | ||
title: createStoryTitle('LimitedTimeBanner'), | ||
component: LimitedTimeBanner, | ||
args: { | ||
HoursRemaining: '2 Hours Remaining' | ||
}, | ||
} as Meta; | ||
|
||
export const Basic: Story<LimitedTimeBannerProps> = (args) => ( | ||
<LimitedTimeBanner {...args}/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import {Clock} from '@styled-icons/bootstrap/Clock'; | ||
import { MainInterface} from '@Utils/BaseStyles'; | ||
|
||
export interface LimitedTimeBannerProps | ||
extends MainInterface { | ||
HoursRemaining: number, | ||
} | ||
|
||
export const LimitedTimeBanner: React.FC<LimitedTimeBannerProps> = ({ | ||
HoursRemaining,...props | ||
}): React.ReactElement => ( | ||
<BannerBox {...props}> | ||
<Icon /> | ||
<p>{HoursRemaining} Hours Remaining</p> | ||
</BannerBox> | ||
) ; | ||
|
||
const BannerBox = styled.div` | ||
// Theme Stuff | ||
${({theme}):string => ` | ||
font-family: ${theme.font.family}; | ||
color: ${theme.colors.background}}; | ||
`} | ||
background-color: rgba(0,0,0,0.5); | ||
font-size: 25px; | ||
text-align: center; | ||
width: 350px; | ||
height: 40px; | ||
`; | ||
|
||
const Icon = styled(Clock)` | ||
width: 25px; | ||
float: left; | ||
padding-top:5px; | ||
padding-bottom:5px; | ||
padding-left: 5px; | ||
`; | ||
|
||
export default LimitedTimeBanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { LoyaltyPointsProps, LoyaltyPoints } from "../../index"; | ||
import { createStoryTitle } from '../../Constants'; | ||
|
||
export default { | ||
|
||
title: createStoryTitle('LoyaltyPoints'), | ||
component: LoyaltyPoints, | ||
args:{ | ||
amount: '+10★' | ||
} | ||
}as Meta; | ||
|
||
|
||
export const Basic: Story<LoyaltyPointsProps> = (args) => ( | ||
<LoyaltyPoints {...args}/> | ||
) | ||
|
||
// todo switch star from text to icon using styled-icons import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { MainInterface } from '@Utils/BaseStyles' | ||
|
||
export const LoyaltyPoints: React.FC<LoyaltyPointsProps> = ({ | ||
amount, ...props | ||
}):React.ReactElement => <LoyaltyPointsBox {...props}><p>{amount}</p></LoyaltyPointsBox>; | ||
|
||
export interface LoyaltyPointsProps | ||
extends MainInterface{ | ||
amount: string; | ||
} | ||
|
||
const LoyaltyPointsBox = styled.div` | ||
|
||
${({theme}):string => ` | ||
font-family: ${theme.font.family}; | ||
font-size: 20px; | ||
width: 60px; | ||
height: 30px; | ||
padding: 5px -10px; | ||
border-radius:50px; | ||
border-bottom-left-radius: 0px; | ||
border-top-left-radius: 0px; | ||
background-color: ${theme.colors.background}; | ||
text-align: center; | ||
color: ${theme.colors.loyaltyText}; | ||
|
||
`} | ||
|
||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { MenuItemCard, MenuItemCardProps, LoyaltyPoints, LimitedTimeBanner, SaleTag} from '../../index'; | ||
import { createStoryTitle } from '../../Constants'; | ||
|
||
export default { | ||
title: createStoryTitle('MenuItemCard'), | ||
component: MenuItemCard, | ||
subcomponents: {LoyaltyPoints, LimitedTimeBanner, SaleTag}, | ||
argTypes: { onClick: { action: 'Link to next step' } }, | ||
args: { | ||
animated: true, | ||
flat: false, | ||
widthFitContent: false, | ||
sale: false, | ||
soldOut: false, | ||
loyaltyPointsToggle: true, | ||
limitedTimeBannerToggle: true, | ||
saleTagToggle: true, | ||
ItemImage: 'https://keyassets-p2.timeincuk.net/wp/prod/wp-content/uploads/sites/63/2007/09/Ricotta-cheese-pancakes-with-blackberry-butter.jpg', | ||
ItemName: 'Blackberry Pancakes', | ||
ItemPrice: 14.99, | ||
discountAmount: 3, | ||
LoyaltyPoints: ( | ||
<LoyaltyPoints loyaltyAmount={10}/> | ||
), | ||
LimitedTimeBanner:( | ||
<LimitedTimeBanner HoursRemaining= {3}/> | ||
), | ||
SaleTag: ( | ||
<SaleTag saleTagAmount={5}/> | ||
), | ||
}, | ||
} as Meta; | ||
|
||
export const Basic: Story<MenuItemCardProps> = (args) => <MenuItemCard {...args}> <LoyaltyPoints loyaltyAmount={0} {...args}/> | ||
<LimitedTimeBanner HoursRemaining={0} {...args}/> <SaleTag {...args} /> </MenuItemCard>; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Main, MainInterface, Responsive, ResponsiveInterface } from '@Utils/BaseStyles'; | ||
import { transition, } from '@Utils/Mixins'; | ||
import { Container } from '@Containers/FileUpload/StyledComponents'; | ||
// eslint-disable-next-line import/no-cycle | ||
import { Heading } from '../../index'; | ||
|
||
export const ItemCard: React.FC<MenuItemCardProps> = ({ | ||
children, | ||
...props | ||
}): React.ReactElement => <MenuItemCardBox {...props}>{children}</MenuItemCardBox>; | ||
|
||
export interface MenuItemCardProps | ||
extends MainInterface, ResponsiveInterface, React.HTMLAttributes<HTMLDivElement> { | ||
|
||
LoyaltyPoints: React.ReactElement; | ||
LimitedTimeBanner: React.ReactElement; | ||
SaleTag: React.ReactElement; | ||
animated?: boolean; | ||
flat?: boolean; | ||
widthFitContent?: boolean; | ||
sale?: boolean; | ||
soldOut?: boolean; | ||
loyaltyPointsToggle?: boolean; | ||
limitedTimeBannerToggle?: boolean, | ||
saleTagToggle?: boolean, | ||
saleTagAmount: number, | ||
ItemImage: string, | ||
ItemName: string, | ||
ItemPrice: number, | ||
discountAmount: number, | ||
} | ||
|
||
export const MenuItemCard: React.FC<MenuItemCardProps> = ({ | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
LoyaltyPoints, | ||
LimitedTimeBanner, | ||
SaleTag, | ||
animated, | ||
flat, | ||
widthFitContent, | ||
sale, | ||
soldOut, | ||
saleTagAmount, | ||
loyaltyPointsToggle, | ||
limitedTimeBannerToggle, | ||
saleTagToggle, | ||
ItemImage, | ||
ItemName, | ||
ItemPrice, | ||
discountAmount, | ||
...props | ||
|
||
}): React.ReactElement => ( | ||
<ItemCard {...props} ItemImage={ItemImage} ItemName={ItemName} ItemPrice={ItemPrice} discountAmount={discountAmount} animated={animated} | ||
flat={flat} widthFitContent={widthFitContent} sale={sale} soldOut={soldOut} LoyaltyPoints = {LoyaltyPoints} saleTagAmount = {saleTagAmount} | ||
loyaltyPointsToggle={loyaltyPointsToggle} LimitedTimeBanner = {LimitedTimeBanner} SaleTag = {SaleTag} saleTagToggle = {saleTagToggle} | ||
limitedTimeBannerToggle={limitedTimeBannerToggle}> | ||
|
||
<img src={ItemImage} alt={ItemName} style={{ width: 350, height: 200 }} /> | ||
<Heading bold>{ItemName}</Heading> | ||
|
||
{ limitedTimeBannerToggle && <Container><LimitedTimeBannerPosition>{LimitedTimeBanner}</LimitedTimeBannerPosition></Container> } | ||
{ saleTagToggle && <Container><SaleTagPosition>{SaleTag}</SaleTagPosition></Container>} | ||
{ loyaltyPointsToggle && <Container><LoyaltyPointsPosition>{LoyaltyPoints}</LoyaltyPointsPosition></Container> } | ||
|
||
{ sale? | ||
<> | ||
<SalePropsSlash>{ItemPrice}</SalePropsSlash> | ||
<OnSale>{ItemPrice - saleTagAmount}</OnSale> | ||
</> | ||
: | ||
<SaleProps>{ItemPrice}</SaleProps> | ||
} | ||
|
||
</ItemCard> | ||
); | ||
|
||
const MenuItemCardBox = styled.div<MenuItemCardProps & MainInterface & ResponsiveInterface>` | ||
position: relative; | ||
background-color: white; | ||
width: 350px; | ||
height: 350px; | ||
|
||
${({ theme, ...props }): string => ` | ||
border-radius: ${theme.dimensions.radius}; | ||
font-family: ${theme.font.family}; | ||
padding: ${theme.dimensions.padding.container}; | ||
|
||
${Main({ | ||
...props, | ||
})} `} | ||
|
||
box-shadow: ${({ flat, theme }): string => theme.depth[flat ? 0 : 1]}; | ||
|
||
${({ animated, flat, theme }): string => | ||
animated ? ` ${transition(['box-shadow'])} &:hover { | ||
box-shadow: ${theme.depth[flat ? 1 : 2]}; | ||
}` : ''} | ||
|
||
${Responsive} | ||
|
||
${({ soldOut }) => | ||
soldOut && ` | ||
opacity: 0.5; | ||
cursor: not-allowed; `} | ||
|
||
${({ widthFitContent }): string => `${widthFitContent ? 'width:fit-content;' : ''} `} | ||
`; | ||
|
||
const SaleProps = styled.header` | ||
font-size: 30px; | ||
text-align: right; | ||
` | ||
const OnSale = styled.header` | ||
font-size: 40px; | ||
text-align: right; | ||
font-weight: bold; | ||
color: #EE2434; | ||
` | ||
const SalePropsSlash = styled(SaleProps)` | ||
text-decoration: line-through; | ||
font-size: 25px; | ||
opacity: .6; | ||
` | ||
const LoyaltyPointsPosition = styled.div` | ||
position: absolute; | ||
top: 30px; | ||
` | ||
const LimitedTimeBannerPosition = styled.div` | ||
position: absolute; | ||
bottom: 150px; | ||
` | ||
const SaleTagPosition = styled.div` | ||
position: absolute; | ||
right: 20px; | ||
top: 30px; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { SaleTag, SaleTagProps } from '../../index'; | ||
import { createStoryTitle } from '../../Constants'; | ||
|
||
export default { | ||
title: createStoryTitle('SaleTag'), | ||
component: SaleTag, | ||
args: { | ||
saleAmount: 2, | ||
}, | ||
} as Meta; | ||
|
||
export const Basic: Story<SaleTagProps> = (args) => ( | ||
<SaleTag {...args}/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
export interface SaleTagProps extends React.HTMLAttributes<HTMLSpanElement> { | ||
saleAmount: number; | ||
} | ||
|
||
export const SaleTag: React.FC<SaleTagProps> = ({ | ||
saleAmount = 2, | ||
...props | ||
}): React.ReactElement => ( | ||
<SaleTagDiv {...props} saleAmount={saleAmount}> | ||
{saleAmount}$ off | ||
</SaleTagDiv> | ||
); | ||
|
||
const SaleTagDiv = styled.span<SaleTagProps>` | ||
${({theme, ...props}):string => ` | ||
border-radius: 100px; | ||
width: 100px; | ||
height: 40px; | ||
padding-left: 10px; | ||
padding-right: 10px; | ||
padding-top: 3px; | ||
padding-bottom: 3px; | ||
border-style: solid; | ||
border-width: 1px; | ||
font-size: 15px; | ||
|
||
background-color: ${theme.colors.background}; | ||
color: ${theme.colors.primary}; | ||
border-color: ${theme.colors.border}; | ||
font-family: ${theme.font.family}; | ||
font-weight: bolder; | ||
text-align: center; | ||
`} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in gitignore??