Skip to content

Commit

Permalink
Merge pull request #1495 from Kajabi/SAGE-545_qj-modalcontent-gap
Browse files Browse the repository at this point in the history
[SAGE-545] Modal - add gap property
  • Loading branch information
QuintonJason authored Jul 7, 2022
2 parents c6c5790 + 0d4e568 commit b0abee5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
} do %>
<%= sage_component SageModalContent, {
title: "Example Spaced Modal",
gap: "lg",
spacing: "panel",
} do %>
<% content_for :sage_header_aside do %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class SageModalContent < SageComponent
set_attribute_schema({
gap: [:optional, NilClass, SageSchemas::GRID_GAP_OPTION],
header_icon: [:optional, {
color: [:optional, SageSchemas::COLOR_SLIDER],
name: SageSchemas::ICON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<div
class="
sage-modal__content
<%= "sage-grid-gap-#{component.gap}" if component.gap %>
<%= "sage-modal__content--spacing-#{component.spacing}" if component.spacing.present? %>
<%= component.generated_css_classes %>"
<%= component.generated_html_attributes.html_safe %>
Expand Down
7 changes: 6 additions & 1 deletion packages/sage-react/lib/themes/next/Modal/Modal.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ const DefaultBody = ({ onExit }) => (
</Button>
)}
/>
<Modal.Body>
<Modal.Body gap={Modal.Body.GAP_OPTIONS.LG}>
<p className={SageClassnames.TYPE.BODY}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
</p>
<p className={SageClassnames.TYPE.BODY}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore
Expand Down
7 changes: 6 additions & 1 deletion packages/sage-react/lib/themes/next/Modal/ModalBody.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { MODAL_CONTENT_SPACINGS } from './configs';
import { MODAL_CONTENT_GAP_OPTIONS, MODAL_CONTENT_SPACINGS } from './configs';

export const ModalBody = ({
children,
className,
gap,
spacing,
...rest
}) => {
const classNames = classnames(
'sage-modal__content',
className,
{
[`sage-grid-gap-${gap}`]: gap,
[`sage-modal__content--spacing-${spacing}`]: spacing,
}
);
Expand All @@ -24,16 +26,19 @@ export const ModalBody = ({
);
};

ModalBody.GAP_OPTIONS = MODAL_CONTENT_GAP_OPTIONS;
ModalBody.SPACINGS = MODAL_CONTENT_SPACINGS;

ModalBody.defaultProps = {
children: null,
className: '',
gap: MODAL_CONTENT_GAP_OPTIONS.DEFAULT,
spacing: ModalBody.SPACINGS.DEFAULT,
};

ModalBody.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
gap: PropTypes.oneOf(Object.values(ModalBody.GAP_OPTIONS)),
spacing: PropTypes.oneOf(Object.values(ModalBody.SPACINGS)),
};
8 changes: 8 additions & 0 deletions packages/sage-react/lib/themes/next/Modal/configs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export const MODAL_CONTENT_GAP_OPTIONS = {
DEFAULT: null,
XS: 'xs',
SM: 'sm',
MD: 'md',
LG: 'lg',
};

export const MODAL_CONTENT_SPACINGS = {
CARD: 'card',
DEFAULT: null,
Expand Down

0 comments on commit b0abee5

Please sign in to comment.