Skip to content

Commit

Permalink
Plan page styling (#1033)
Browse files Browse the repository at this point in the history
* feat: layout

* feat: layout and help text

* faet: mobile layout

* feat: layout and button size
  • Loading branch information
WendellLiu authored Nov 29, 2022
1 parent adca23e commit e7daa29
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}

.content {
padding: 26px 78px;
display: flex;
flex-direction: column;
align-items: center;
Expand Down
26 changes: 2 additions & 24 deletions src/components/PlanPage/CardSection.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';

import P from 'common/base/P';
import { subscriptionType } from 'constants/subscription';

import PlanCard from './PlanCard';
import styles from './CardSection.module.css';
import { getColumns } from './helpers';

const getTitleClassName = type => {
if (type === subscriptionType.submitData) {
return 'titleSubmitData';
}

return 'titleBuySubscription';
};

const CardSection = ({ plans, title, type }) => {
const CardSection = ({ plans }) => {
return (
<div>
<P
className={styles[getTitleClassName(type)]}
size="m"
style={{
marginBottom: '12px',
}}
>
{title}
</P>
<div
className={styles.cardContainer}
style={{
Expand All @@ -41,7 +21,7 @@ const CardSection = ({ plans, title, type }) => {
description={plan.description}
amount={plan.amount}
actionUrl={plan.url}
type={type}
type={plan.type}
/>
</div>
))}
Expand All @@ -52,8 +32,6 @@ const CardSection = ({ plans, title, type }) => {

CardSection.propTypes = {
plans: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string,
type: PropTypes.string,
};

export default CardSection;
10 changes: 1 addition & 9 deletions src/components/PlanPage/CardSection.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@media (min-width: above-tablet) {
display: grid;
column-gap: 20px;
column-gap: 32px;
}
}

Expand All @@ -17,11 +17,3 @@
margin-bottom: 0;
}
}

.titleSubmitData {
color: yellow-dark;
}

.titleBuySubscription {
color: warning-red;
}
40 changes: 27 additions & 13 deletions src/components/PlanPage/PlanCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ const getButtonType = type => {

const PlanCard = ({ title, description, amount, actionUrl, type }) => {
const actionTitle = getActionTitle(type);

const isSubmitData = type === subscriptionType.submitData;
return (
<RoundCard>
<RoundCard className={styles.container}>
<div className={styles.content}>
<Heading Tag="h3" size="sm" className={styles.title} bold>
{title}
</Heading>
<P className={styles.description}>{description}</P>
<div className={styles.topArea}>
<Heading Tag="h3" size="sm" className={styles.title} bold>
{title}
</Heading>
<P className={styles.description}>{description}</P>
</div>
<div className={styles.amountSection}>
<P className={styles.amount} bold>
{amount}
Expand All @@ -35,14 +39,24 @@ const PlanCard = ({ title, description, amount, actionUrl, type }) => {
</P>
</div>
<Link to={actionUrl}>
<Button
className={styles.actionButton}
btnStyle={getButtonType(type)}
>
{actionTitle}
</Button>
</Link>
<div className={styles.bottomArea}>
<div className={styles.helperContainer}>
{isSubmitData && (
<P className={styles.helperText} size="s">
\ 留下你的資料幫助其他人 /
</P>
)}
</div>
<Link to={actionUrl}>
<Button
className={styles.actionButton}
btnStyle={getButtonType(type)}
circleSize="lg"
>
{actionTitle}
</Button>
</Link>
</div>
</div>
</RoundCard>
);
Expand Down
34 changes: 31 additions & 3 deletions src/components/PlanPage/PlanCard.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
@value above-tablet, main-gray from "common/variables.module.css";
@value above-tablet, main-gray, yellow-dark from "common/variables.module.css";

.container {
height: 390px;
width: 300px;
padding: 26px 0;
}

.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
height: 100%;
}

.actionButton {
margin-top: 16px;
width: 140px;
height: 45px;
}

.title {
Expand All @@ -16,16 +26,34 @@
}

.description {
margin-bottom: 56px;
}

.amountSection {
display: flex;
align-items: center;
margin-bottom: 82px;
}

.amount {
font-size: 56px;
margin-right: 20px;
}

.topArea {
display: flex;
flex-direction: column;
align-items: center;
}

.bottomArea {
display: flex;
flex-direction: column;
align-items: center;
}

.helperText {
color: yellow-dark;
}

.helperContainer {
min-height: 20px;
}
8 changes: 6 additions & 2 deletions src/components/PlanPage/PlanPage.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@value above-tablet from "common/variables.module.css";

.container {
padding: 50px 0 0 0;
padding-top: 20px;

@media (min-width: above-tablet) {
padding-top: 50px;
}
}

.content {
Expand All @@ -11,7 +15,7 @@
}

.title {
margin-bottom: 24px;
display: none;

@media (min-width: above-tablet) {
margin-bottom: 70px;
Expand Down
4 changes: 1 addition & 3 deletions src/components/PlanPage/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compose, length, min, groupBy, prop } from 'ramda';
import { compose, length, min } from 'ramda';
import { subscriptionType } from 'constants/subscription';

const MAX_COLUMN = 3;
Expand All @@ -15,5 +15,3 @@ export const getActionTitle = type => {

return '付費解鎖';
};

export const groupByPlanType = groupBy(prop('type'));
14 changes: 1 addition & 13 deletions src/components/PlanPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { subscriptionType } from 'constants/subscription';

import styles from './PlanPage.module.css';
import CardSection from './CardSection';
import { groupByPlanType } from './helpers';

const plans = [
{
Expand Down Expand Up @@ -35,11 +34,6 @@ const plans = [
];

const PlanPage = () => {
const groupedPlans = groupByPlanType(plans);

const hasSubmitDataPlan =
groupedPlans[subscriptionType.submitData].length > 0;

return (
<div className={styles.container}>
<div className={styles.content}>
Expand All @@ -48,16 +42,10 @@ const PlanPage = () => {
</Heading>
<div className={styles['cardSection']}>
<CardSection
plans={groupedPlans[subscriptionType.submitData]}
plans={plans}
title="留下你的資料幫助其他人:"
type={subscriptionType.submitData}
/>
{hasSubmitDataPlan && <div className={styles.divider}>或是</div>}
<CardSection
plans={groupedPlans[subscriptionType.buySubscription]}
title="線上付費解鎖全站資料:"
type={subscriptionType.buySubscription}
/>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/common/RoundCard/RoundCard.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@value card-border-gray, warning-red from "common/variables.module.css";

.container {
padding: 26px 78px;
border: 1px solid card-border-gray;
border-radius: 8px;
background-color: white;
Expand Down

0 comments on commit e7daa29

Please sign in to comment.