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

[Wave8] Create a Workspace Card #32339

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d254e4f
Create a Workspace card
MaciejSWM Dec 1, 2023
fa86c13
Workspace title and icon
MaciejSWM Dec 4, 2023
957cab8
Merge branch 'main' into wave8/create-a-workspace-card
MaciejSWM Dec 4, 2023
294bca6
Let Icon be at the top or on the right
MaciejSWM Dec 4, 2023
79fbdb1
Add muted subtitle
MaciejSWM Dec 4, 2023
0f16ecf
Remove Create a Workspace card
MaciejSWM Dec 4, 2023
2122277
Drop unused imports
MaciejSWM Dec 4, 2023
8aea9bb
Add Hotdog stand icon
MaciejSWM Dec 4, 2023
4526678
Merge branch 'main' into wave8/create-a-workspace-card
MaciejSWM Dec 5, 2023
bf42670
Approved spanish translations
MaciejSWM Dec 5, 2023
d76eeef
Revert color changes
MaciejSWM Dec 5, 2023
74dc5cc
Merge branch 'main' into wave8/create-a-workspace-card
MaciejSWM Dec 13, 2023
9146059
Make styles naming more general
MaciejSWM Dec 13, 2023
73721d1
Card layout as const
MaciejSWM Dec 13, 2023
7178306
Medium sized button
MaciejSWM Dec 13, 2023
04d59f3
Empty workspace translations
MaciejSWM Dec 13, 2023
3988d7f
Merge branch 'main' into wave8/create-a-workspace-card
MaciejSWM Dec 14, 2023
cd85712
Change import path
MaciejSWM Dec 14, 2023
9da1c8e
Only apply mh1 on single layout
MaciejSWM Dec 18, 2023
5d3d93a
Bool instead of boolean
MaciejSWM Dec 18, 2023
0cc848e
Use useLocalize instead of withLocalize
MaciejSWM Dec 18, 2023
91b8e91
Spread array of styles
MaciejSWM Dec 18, 2023
5e800a2
Split Section to index.js and IconSection.js
MaciejSWM Dec 18, 2023
6fd3b5a
Drop Section.js after pushing it to a separate directory
MaciejSWM Dec 18, 2023
0ea0c16
Merge branch 'main' into wave8/create-a-workspace-card
MaciejSWM Dec 20, 2023
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/DatePicker/CalendarPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class CalendarPicker extends React.PureComponent {
<View
style={[
this.props.themeStyles.calendarDayContainer,
isSelected ? this.props.themeStyles.calendarDayContainerSelected : {},
isSelected ? this.props.themeStyles.buttonDefaultBG : {},
!isDisabled ? this.props.StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed)) : {},
]}
>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import ConciergeNew from '@assets/images/simple-illustrations/simple-illustratio
import CreditCardsNew from '@assets/images/simple-illustrations/simple-illustration__credit-cards.svg';
import EmailAddress from '@assets/images/simple-illustrations/simple-illustration__email-address.svg';
import HandEarth from '@assets/images/simple-illustrations/simple-illustration__handearth.svg';
import HotDogStand from '@assets/images/simple-illustrations/simple-illustration__hotdogstand.svg';
import InvoiceBlue from '@assets/images/simple-illustrations/simple-illustration__invoice.svg';
import LockOpen from '@assets/images/simple-illustrations/simple-illustration__lockopen.svg';
import Luggage from '@assets/images/simple-illustrations/simple-illustration__luggage.svg';
Expand All @@ -60,6 +61,7 @@ export {
ConciergeExclamation,
CreditCardsBlue,
EmailAddress,
HotDogStand,
InvoiceOrange,
JewelBoxBlue,
JewelBoxGreen,
Expand Down
2 changes: 1 addition & 1 deletion src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ function MenuItem(
{badgeText && (
<Badge
text={badgeText}
badgeStyles={[styles.alignSelfCenter, brickRoadIndicator ? styles.mr2 : undefined, focused || isHovered || pressed ? styles.hoveredButton : {}]}
badgeStyles={[styles.alignSelfCenter, brickRoadIndicator ? styles.mr2 : undefined, focused || isHovered || pressed ? styles.buttonHoveredBG : {}]}
/>
)}
{/* Since subtitle can be of type number, we should allow 0 to be shown */}
Expand Down
40 changes: 40 additions & 0 deletions src/components/Section/IconSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
import useThemeStyles from '@hooks/useThemeStyles';
Comment on lines +1 to +5
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have some dependency which is not migrated to TS or can we make this in TS now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe at the time of Section/index.js (originally Section.js) migration


const iconSectionPropTypes = {
icon: PropTypes.icon,
IconComponent: PropTypes.IconComponent,
iconContainerStyles: PropTypes.iconContainerStyles,
Comment on lines +8 to +10
Copy link
Contributor

Choose a reason for hiding this comment

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

@MaciejSWM would you mind working on #25024?
As these are wrong prop types, we have console warning. TS migration should fix it.

console

Copy link
Contributor

Choose a reason for hiding this comment

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

Bumped that issue

Copy link
Contributor

Choose a reason for hiding this comment

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

I fixed that here @aimane-chnaif, funny enough you where chosen for C+ review 😸

};

const defaultIconSectionPropTypes = {
icon: null,
IconComponent: null,
iconContainerStyles: [],
};

function IconSection({icon, IconComponent, iconContainerStyles}) {
const styles = useThemeStyles();

return (
<View style={[styles.flexGrow1, styles.flexRow, styles.justifyContentEnd, ...iconContainerStyles]}>
{Boolean(icon) && (
<Icon
src={icon}
height={68}
width={68}
/>
)}
{Boolean(IconComponent) && <IconComponent />}
</View>
);
}

IconSection.displayName = 'IconSection';
IconSection.propTypes = iconSectionPropTypes;
IconSection.defaultProps = defaultIconSectionPropTypes;

export default IconSection;
57 changes: 38 additions & 19 deletions src/components/Section.js → src/components/Section/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import MenuItemList from '@components/MenuItemList';
import menuItemPropTypes from '@components/menuItemPropTypes';
import Text from '@components/Text';
import useThemeStyles from '@hooks/useThemeStyles';
import Icon from './Icon';
import MenuItemList from './MenuItemList';
import menuItemPropTypes from './menuItemPropTypes';
import Text from './Text';
import IconSection from './IconSection';

const CARD_LAYOUT = {
ICON_ON_TOP: 'iconOnTop',
ICON_ON_RIGHT: 'iconOnRight',
};

const propTypes = {
/** An array of props that are pass to individual MenuItem components */
Expand All @@ -23,6 +28,10 @@ const propTypes = {
/** Icon component */
IconComponent: PropTypes.func,

/** Card layout that affects icon positioning, margins, sizes. */
// eslint-disable-next-line rulesdir/prefer-underscore-method
cardLayout: PropTypes.oneOf(Object.values(CARD_LAYOUT)),

/** Contents to display inside the section */
children: PropTypes.node,

Expand All @@ -38,6 +47,9 @@ const propTypes = {
// eslint-disable-next-line react/forbid-prop-types
subtitleStyles: PropTypes.arrayOf(PropTypes.object),

/** Whether the subtitle should have a muted style */
subtitleMuted: PropTypes.bool,

/** Customize the Section container */
// eslint-disable-next-line react/forbid-prop-types
childrenStyles: PropTypes.arrayOf(PropTypes.object),
Expand All @@ -52,38 +64,45 @@ const defaultProps = {
children: null,
icon: null,
IconComponent: null,
cardLayout: CARD_LAYOUT.ICON_ON_RIGHT,
containerStyles: [],
iconContainerStyles: [],
titleStyles: [],
subtitleStyles: [],
subtitleMuted: false,
childrenStyles: [],
subtitle: null,
};

function Section({children, childrenStyles, containerStyles, icon, IconComponent, iconContainerStyles, menuItems, subtitle, subtitleStyles, title, titleStyles}) {
function Section({children, childrenStyles, containerStyles, icon, IconComponent, cardLayout, iconContainerStyles, menuItems, subtitle, subtitleStyles, subtitleMuted, title, titleStyles}) {
const styles = useThemeStyles();

return (
<>
<View style={[styles.pageWrapper, styles.cardSection, ...containerStyles]}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.w100, ...titleStyles]}>
{cardLayout === CARD_LAYOUT.ICON_ON_TOP && (
<IconSection
icon={icon}
IconComponent={IconComponent}
iconContainerStyles={[...iconContainerStyles, styles.alignSelfStart, styles.mb3]}
/>
)}
<View style={[styles.flexRow, styles.alignItemsCenter, styles.w100, cardLayout === CARD_LAYOUT.ICON_ON_TOP && styles.mh1, ...titleStyles]}>
<View style={[styles.flexShrink1]}>
<Text style={[styles.textHeadline, styles.cardSectionTitle]}>{title}</Text>
</View>
<View style={[styles.flexGrow1, styles.flexRow, styles.justifyContentEnd, ...iconContainerStyles]}>
{Boolean(icon) && (
<Icon
src={icon}
height={68}
width={68}
/>
)}
{Boolean(IconComponent) && <IconComponent />}
</View>
{cardLayout === CARD_LAYOUT.ICON_ON_RIGHT && (
<IconSection
icon={icon}
IconComponent={IconComponent}
iconContainerStyles={iconContainerStyles}
/>
)}
</View>

{Boolean(subtitle) && (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.w100, styles.mt4, ...subtitleStyles]}>
<Text style={styles.textNormal}>{subtitle}</Text>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.w100, cardLayout === CARD_LAYOUT.ICON_ON_TOP ? [styles.mt1, styles.mh1] : styles.mt4, ...subtitleStyles]}>
<Text style={[styles.textNormal, subtitleMuted && styles.colorMuted]}>{subtitle}</Text>
</View>
)}

Expand All @@ -94,9 +113,9 @@ function Section({children, childrenStyles, containerStyles, icon, IconComponent
</>
);
}

Section.displayName = 'Section';
Section.propTypes = propTypes;
Section.defaultProps = defaultProps;

export {CARD_LAYOUT};
export default Section;
5 changes: 3 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1489,8 +1489,9 @@ export default {
mustBeOnlineToViewMembers: 'You must be online in order to view members of this workspace.',
},
emptyWorkspace: {
title: 'Create a new workspace',
subtitle: "Workspaces are where you'll chat with your team, reimburse expenses, issue cards, send invoices, pay bills, and more — all in one place.",
title: 'Create a workspace',
subtitle: 'Manage business expenses, issue cards, send invoices, and more.',
createAWorkspaceCTA: 'Get Started',
features: {
trackAndCollect: 'Track and collect receipts',
companyCards: 'Company credit cards',
Expand Down
5 changes: 3 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,9 @@ export default {
mustBeOnlineToViewMembers: 'Debes estar en línea para poder ver los miembros de este espacio de trabajo.',
},
emptyWorkspace: {
title: 'Crear un nuevo espacio de trabajo',
subtitle: 'En los espacios de trabajo es donde puedes chatear con tu equipo, reembolsar gastos, emitir tarjetas, enviar y pagar facturas y mas — todo en un mismo lugar',
title: 'Crea un espacio de trabajo',
subtitle: 'Administra gastos de empresa, emite tarjetas, envía facturas y mucho más.',
createAWorkspaceCTA: 'Comenzar',
features: {
trackAndCollect: 'Organiza recibos',
companyCards: 'Tarjetas de crédito corporativas',
Expand Down
33 changes: 33 additions & 0 deletions src/pages/workspace/card/WorkspaceCardCreateAWorkspace.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import Button from '@components/Button';
import * as Illustrations from '@components/Icon/Illustrations';
import Section, {CARD_LAYOUT} from '@components/Section';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';

function WorkspaceCardCreateAWorkspace() {
const styles = useThemeStyles();
const {translate} = useLocalize();

return (
<Section
title={translate('workspace.emptyWorkspace.title')}
icon={Illustrations.HotDogStand}
cardLayout={CARD_LAYOUT.ICON_ON_TOP}
subtitle={translate('workspace.emptyWorkspace.subtitle')}
subtitleMuted
containerStyles={[styles.highlightBG]}
>
<Button
text={translate('workspace.emptyWorkspace.createAWorkspaceCTA')}
style={styles.mt5}
success
medium
/>
</Section>
);
}

WorkspaceCardCreateAWorkspace.displayName = 'WorkspaceCardNoVBAView';

export default WorkspaceCardCreateAWorkspace;
10 changes: 5 additions & 5 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,14 @@ const styles = (theme: ThemeColors) =>
overflow: 'hidden',
},

calendarDayContainerSelected: {
buttonDefaultBG: {
backgroundColor: theme.buttonDefaultBG,
},

buttonHoveredBG: {
backgroundColor: theme.buttonHoveredBG,
},

autoGrowHeightInputContainer: (textInputHeight: number, minHeight: number, maxHeight: number) =>
({
height: lodashClamp(textInputHeight, minHeight, maxHeight),
Expand Down Expand Up @@ -1952,10 +1956,6 @@ const styles = (theme: ThemeColors) =>
alignSelf: 'flex-end',
},

hoveredButton: {
backgroundColor: theme.buttonHoveredBG,
},

composerSizeButton: {
alignSelf: 'center',
height: 32,
Expand Down
Loading