Skip to content

Commit f20d5e4

Browse files
authored
Merge pull request #179 from reusejs/StoreButtonFix
Store button fix
2 parents db9c67f + b6ac13d commit f20d5e4

4 files changed

Lines changed: 57 additions & 13 deletions

File tree

.changeset/curvy-ducks-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@reusejs/react": patch
3+
---
4+
5+
Store Button Enhancements

apps/storybook/src/stories/docs/StoreButton.docs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ This is sample templates of store buttons. Both Play store and app store.
44
This template only accept two props:
55
1. **storeName** : Which can have two values **\`google\`** and **\`apple\`**, one for each store. This prop is **mandatory**
66
2. **mode** : This prop can have two values **\`dark\`** and **\`light\`**, Default value is \`light\` if no value is given.
7+
3. **responsive** : This prop can have a boolean value i.e. *\`true\`* or *\`false\`*. Default value is true. If false is given the button will not be responsive. Sample3 and Sample6 shows the non-responsive button example while the other examples features a responsive button.
78
89
> This is for demo pupose only. Please copy the code fragment for ButtonBase and use as you see fit for any radical customisation
910
`;
1011

11-
export default docs;
12+
export default docs;

apps/storybook/src/stories/templates/StoreButton.stories.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { ComponentStory, ComponentMeta } from '@storybook/react';
33
import StoreButtonDocs from '../docs/StoreButton.docs';
4-
54
import { StoreButton } from '@reusejs/react';
65

76
export default {
@@ -33,20 +32,33 @@ Sample2.args = {
3332
storeName: 'apple',
3433
};
3534

35+
export const Sample3 = Template.bind({});
36+
Sample3.args = {
37+
storeName: 'apple',
38+
responsive: false,
39+
};
40+
3641
const Template2: ComponentStory<typeof StoreButton> = (args) => (
3742
<div className='flex h-40 items-center justify-center bg-black'>
3843
<StoreButton {...args} />
3944
</div>
4045
);
4146

42-
export const Sample3 = Template2.bind({});
43-
Sample3.args = {
47+
export const Sample4 = Template2.bind({});
48+
Sample4.args = {
4449
storeName: 'google',
4550
mode: 'dark',
4651
};
4752

48-
export const Sample4 = Template2.bind({});
49-
Sample4.args = {
53+
export const Sample5 = Template2.bind({});
54+
Sample5.args = {
55+
storeName: 'apple',
56+
mode: 'dark',
57+
};
58+
59+
export const Sample6 = Template2.bind({});
60+
Sample6.args = {
5061
storeName: 'apple',
5162
mode: 'dark',
63+
responsive: false,
5264
};

packages/react/src/templates/StoreButtonTemplates/storeButton.tsx

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@ import PlayStoreLogo from "./PlayStoreLogo";
77
export interface StoreButtonInterface {
88
storeName: "google" | "apple";
99
mode?: "dark" | "light" | undefined;
10+
responsive?: boolean;
11+
}
12+
13+
export interface ContentProps {
14+
responsive: boolean;
1015
}
1116

1217
const appStoreText = ["Download on the", " App Store"];
1318
const playStoreText = ["GET IT ON", " Google Play"];
1419

15-
const Play = () => {
20+
const Play = (props: ContentProps) => {
21+
const style = props.responsive
22+
? "hidden md:ml-1 md:flex md:flex-col"
23+
: "ml-1 flex flex-col";
1624
return (
17-
<div className="ml-1 flex flex-col">
25+
<div className={style}>
1826
<p className="text-left text-sm font-semibold leading-tight">
1927
{playStoreText[0]}
2028
</p>
@@ -23,9 +31,12 @@ const Play = () => {
2331
);
2432
};
2533

26-
const App = () => {
34+
const App = (props: ContentProps) => {
35+
const style = props.responsive
36+
? "hidden md:flex md:flex-col"
37+
: "flex flex-col";
2738
return (
28-
<div className="flex flex-col">
39+
<div className={style}>
2940
<p className="w-full text-sm leading-tight">{appStoreText[0]}</p>
3041
<p className="w-full scale-x-125 text-lg font-bold leading-tight">
3142
{appStoreText[1]}
@@ -38,19 +49,29 @@ const StoreButton = (props: StoreButtonInterface) => {
3849
let parms = {
3950
backgroundColor: "bg-white hover:shadow-xl",
4051
border: "border-2 border-black",
41-
font: "text-black",
52+
borderRadius: props.responsive
53+
? "rounded-full md:rounded-md"
54+
: "rounded-md",
55+
textColor: "text-black",
56+
padding: props.responsive ? "px-3 py-3 md:px-4 md:py-2" : "px-4 py-2",
4257
};
4358
if (props.mode === "dark") {
4459
parms = {
4560
...parms,
4661
backgroundColor: "bg-black hover:shadow-lg hover:shadow-white ",
4762
border: "border-2 border-white",
48-
font: "text-white",
63+
textColor: "text-white",
4964
};
5065
}
5166
return (
5267
<ButtonBase
53-
label={props.storeName === "google" ? <Play /> : <App />}
68+
label={
69+
props.storeName === "google" ? (
70+
<Play responsive={props.responsive as boolean} />
71+
) : (
72+
<App responsive={props.responsive as boolean} />
73+
)
74+
}
5475
buttonBaseClasses={{ ...parms }}
5576
buttonPrefix={
5677
props.storeName === "google" ? (
@@ -63,4 +84,9 @@ const StoreButton = (props: StoreButtonInterface) => {
6384
);
6485
};
6586

87+
StoreButton.defaultProps = {
88+
mode: "light",
89+
responsive: true,
90+
};
91+
6692
export default StoreButton;

0 commit comments

Comments
 (0)