Skip to content

Commit

Permalink
feat(SettingsPageItem): Added danger prop
Browse files Browse the repository at this point in the history
  • Loading branch information
artalat committed Jul 25, 2022
1 parent 98bed69 commit 5e0e022
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default createPlugin({
...settings,
...layouts,

SettingsPageItem: SettingsPageItem
SettingsPageItem: SettingsPageItem,
},

indexRoute: 'SettingsApp',
Expand Down
2 changes: 2 additions & 0 deletions src/layouts/SettingsPageItem/SettingsPageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface SettingsPageItemProps {
/** Styles to apply to the description component */
descriptionStyle?: TextStyle;

danger?: boolean;

children?: React.ReactNode;
style?: ViewStyle;
}
Expand Down
71 changes: 38 additions & 33 deletions src/layouts/SettingsPageItem/SettingsPageItemDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,44 @@ export interface SettingsPageItemDesktopProps extends SettingsPageItemProps {
styles?: Partial<SettingsPageItemDesktopStyles>;
}

const defaultStyles = (theme: Theme): SettingsPageItemDesktopStyles => ({
root: {
backgroundColor: theme.palette.background.card,
borderColor: theme.palette.divider,
borderRadius: theme.shape.borderRadius * 2,
borderWidth: 1,
overflow: 'hidden',
},

header: {
borderBottomColor: theme.palette.divider,
borderBottomWidth: 1,
paddingHorizontal: theme.spacing.unit * 2,
paddingVertical: theme.spacing.unit,
},

titleStyles: {
paddingVertical: theme.spacing.unit / 2,
},

descriptionStyles: {
color: theme.palette.text.hint,
paddingVertical: theme.spacing.unit / 2,
},

content: {
// backgroundColor: theme.palette.background.card,
borderBottomWidth: Platform.select({ default: undefined, ios: 1 }),
borderColor: Platform.select({ default: undefined, ios: theme.palette.divider }),
borderTopWidth: Platform.select({ default: undefined, ios: 1 }),
flex: 1,
},
});
const defaultStyles = (theme: Theme, props: SettingsPageItemDesktopProps): SettingsPageItemDesktopStyles => {
const { danger }= props;
return {
root: {
backgroundColor: theme.palette.background.card,
borderColor: danger ? 'rgba(239, 83, 80, .5)' : theme.palette.divider,
borderRadius: theme.shape.borderRadius * 2,
borderWidth: 1,
overflow: 'hidden',
},

header: {
backgroundColor: danger ? 'rgba(239, 83, 80, .1)' : theme.palette.background.card,
borderBottomColor: danger ? 'rgba(239, 83, 80, .5)' : theme.palette.divider,
borderBottomWidth: 1,
paddingHorizontal: theme.spacing.unit * 2,
paddingVertical: theme.spacing.unit,
},

titleStyles: {
color: danger ? 'rgba(239, 83, 80, 1)' : theme.palette.text.primary,
paddingVertical: theme.spacing.unit / 2,
},

descriptionStyles: {
color: danger ? 'rgba(239, 83, 80, .87)' : theme.palette.text.secondary,
paddingVertical: theme.spacing.unit / 2,
},

content: {
// backgroundColor: theme.palette.background.card,
borderBottomWidth: Platform.select({ default: undefined, ios: 1 }),
borderColor: Platform.select({ default: undefined, ios: theme.palette.divider }),
borderTopWidth: Platform.select({ default: undefined, ios: 1 }),
flex: 1,
},
};
};

export const SettingsPageItemDesktop = (props: SettingsPageItemDesktopProps) => {
const { description, descriptionStyle, title, titleStyle, style, component, children } = props;
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/SettingsPageItem/SettingsPageItemMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface SettingsPageItemMobileProps extends SettingsPageItemProps {
styles?: Partial<SettingsPageItemMobileStyles>;
}

const defaultStyles = (theme: Theme): SettingsPageItemMobileStyles => ({
const defaultStyles = (theme: Theme, { danger }: SettingsPageItemMobileProps): SettingsPageItemMobileStyles => ({
contentStyles: {},

descriptionStyles: {
Expand All @@ -33,6 +33,7 @@ const defaultStyles = (theme: Theme): SettingsPageItemMobileStyles => ({
paddingVertical: theme.spacing.unit,
},
titleStyles: {
color: danger ? 'rgba(239, 83, 80, 1)' : theme.palette.text.primary,
paddingVertical: theme.spacing.unit,
},
});
Expand Down

0 comments on commit 5e0e022

Please sign in to comment.