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
Mac-LU-CEM2514-Menu Item Card + Loyalty Points #429
Open
mfnisbetLU
wants to merge
2
commits into
master
Choose a base branch
from
Mac-LU-CEM2514-MenuItemCard
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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -9,14 +9,18 @@ const MINUTES_IN_YEAR = 524160; | |
export interface LimitedTimeBannerProps | ||
extends MainInterface { | ||
/* minutes until time runs out */ | ||
minsRemaining: number, | ||
minsRemaining: number, | ||
bannerWidth?: number, | ||
bannerHeight?: number, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't these live in the props? |
||
} | ||
|
||
export const LimitedTimeBanner: React.FC<LimitedTimeBannerProps> = ({ | ||
minsRemaining, | ||
bannerWidth, | ||
bannerHeight, | ||
...props | ||
}): React.ReactElement => ( | ||
<BannerBox {...props}> | ||
<BannerBox minsRemaining={minsRemaining} bannerWidth={bannerWidth} bannerHeight={bannerHeight} {...props}> | ||
<Icon /> | ||
<BannerHeader> | ||
{alterTime(minsRemaining)} Remaining | ||
|
@@ -47,14 +51,16 @@ const alterTime = (value:number) => { | |
return(moment.duration(value,'minutes').humanize()); | ||
} | ||
|
||
const BannerBox = styled.div` | ||
const BannerBox = styled.div<LimitedTimeBannerProps>` | ||
${({theme}):string => ` | ||
font-family: ${theme.font.family}; | ||
color: ${theme.colors.background}}; | ||
background-color: ${theme.colors.bannerBackgroundColor}; | ||
`} | ||
width:350px; | ||
height:40px; | ||
${({ bannerWidth, bannerHeight }): string => ` | ||
width: ${bannerWidth}px; | ||
height: ${bannerHeight}px; | ||
`} | ||
`; | ||
|
||
const Icon = styled(Clock)` | ||
|
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,17 @@ | ||
import React from 'react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { LoyaltyPointsProps, LoyaltyPoints } from '../../index'; | ||
|
||
export default { | ||
|
||
title: 'Components/LoyaltyPoints', | ||
component: LoyaltyPoints, | ||
args: { | ||
loyaltyamount: 10, | ||
loyaltypointlimit: 100, | ||
} | ||
} as Meta; | ||
|
||
export const Basic: Story<LoyaltyPointsProps> = (args) => ( | ||
<LoyaltyPoints {...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,42 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Stars } from '@styled-icons/material/Stars'; | ||
|
||
export interface LoyaltyPointsProps | ||
extends React.HTMLAttributes<HTMLDivElement> { | ||
loyaltyamount: number; //the amount of loyalty points that the user gets with purchase, used to display on component. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. camelCase |
||
loyaltypointlimit: number; //the limit of loyalty points before it says 99+ instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /** docs */ |
||
} | ||
|
||
export const LoyaltyPoints: React.FC<LoyaltyPointsProps> = ({ | ||
loyaltyamount, | ||
loyaltypointlimit, | ||
...props | ||
}): React.ReactElement => <LoyaltyPointsBox {...props}> | ||
<header>+{getLoyaltyPoints(loyaltyamount, loyaltypointlimit)}<Star /></header> | ||
</LoyaltyPointsBox>; | ||
|
||
function getLoyaltyPoints(loyaltypoints: number, loyaltypointlimit: number) { | ||
if (loyaltypoints >= loyaltypointlimit) { | ||
return loyaltypointlimit + "⁺"; | ||
} | ||
return Math.round(loyaltypoints); | ||
} | ||
|
||
const LoyaltyPointsBox = styled.div` | ||
${({ theme }): string => ` | ||
font-family: ${theme.font.family}; | ||
font-size: 20px; | ||
width: fit-content; | ||
min-width: 60px; | ||
height: 30px; | ||
border-radius:0px 50px 50px 0px; | ||
background-color: ${theme.colors.background}; | ||
color: ${theme.colors.loyaltyText}; | ||
text-align: center; | ||
`} | ||
` | ||
const Star = styled(Stars)` | ||
width: 20px; | ||
height: 20px; | ||
` |
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,86 @@ | ||
import React from 'react'; | ||
import { Meta, Story } from '@storybook/react'; | ||
import { MenuItemCard, MenuItemCardProps, LoyaltyPoints, LimitedTimeBanner, SaleTag } from '../../index'; | ||
|
||
export default { | ||
title: 'Components/Menu Item Card', | ||
component: MenuItemCard, | ||
subcomponents: { LoyaltyPoints, LimitedTimeBanner, SaleTag }, | ||
argTypes: { onClick: { action: 'This card was clicked!' } }, | ||
} as Meta; | ||
|
||
const Template: Story<MenuItemCardProps> = (args) => <MenuItemCard {...args}> <LoyaltyPoints {...args} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use round brackets only do this when it's one line not 3 |
||
<LimitedTimeBanner {...args} /> <SaleTag {...args} /> </MenuItemCard>; | ||
|
||
export const MenuItemCardBasic = Template.bind({}); | ||
MenuItemCardBasic.args = { | ||
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: 15.99, | ||
itemPriceLimit: 1000, | ||
saleAmount: 5, | ||
loyaltyamount: 20, | ||
loyaltypointlimit: 100, | ||
bannerWidth: 280, | ||
bannerHeight: 40, | ||
minsRemaining: 120, | ||
sale: false, | ||
soldOut: false, | ||
animated: true, | ||
flat: false, | ||
}; | ||
|
||
export const MenuItemCardStates = Template.bind({}); | ||
MenuItemCardStates.args = { | ||
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: 15.99, | ||
itemPriceLimit: 1000, | ||
saleAmount: 5, | ||
loyaltyamount: 0, | ||
loyaltypointlimit: 100, | ||
bannerWidth: 300, | ||
bannerHeight: 40, | ||
minsRemaining: 0, | ||
sale: true, | ||
soldOut: true, | ||
animated: false, | ||
flat: false, | ||
}; | ||
|
||
export const MenuItemCardLongText = Template.bind({}); | ||
MenuItemCardLongText.args = { | ||
itemImage: 'https://keyassets-p2.timeincuk.net/wp/prod/wp-content/uploads/sites/63/2007/09/Ricotta-cheese-pancakes-with-blackberry-butter.jpg', | ||
itemName: 'Super crazy long combo special order with extra sides and drinks', | ||
itemPrice: 2560, | ||
itemPriceLimit: 1000, | ||
saleAmount: 200, | ||
loyaltyamount: 1500, | ||
loyaltypointlimit: 1200, | ||
minsRemaining: 24000, | ||
bannerWidth: 300, | ||
bannerHeight: 40, | ||
sale: true, | ||
soldOut: false, | ||
animated: true, | ||
flat: false, | ||
}; | ||
|
||
export const MenuItemCardEmpty = Template.bind({}); | ||
MenuItemCardEmpty.args = { | ||
itemImage: '', | ||
itemName: '', | ||
itemPrice: 0, | ||
itemPriceLimit: 1000, | ||
saleAmount: 0, | ||
loyaltyamount: 0, | ||
loyaltypointlimit: 100, | ||
minsRemaining: 0, | ||
bannerWidth: 300, | ||
bannerHeight: 40, | ||
sale: false, | ||
soldOut: false, | ||
animated: false, | ||
flat: false, | ||
}; | ||
|
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.
Should be optional