Skip to content

Commit

Permalink
refactor: renames scope prop to size
Browse files Browse the repository at this point in the history
  • Loading branch information
anechol committed Jul 31, 2024
1 parent 7d9ce28 commit 5eaf22f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
icon: "bold",
title: "Title for state, compact variety",
text: "Text to appear below. Lorem ipsum dolor sit amet consectituor.",
scope: "compact",
size: "compact",
} do %>
<p>Other stuff such as buttons...</p>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class SageEmptyState < SageComponent
center_vertical: [:optional, NilClass, TrueClass],
graphic: [:optional, NilClass, String],
icon: [:optional, NilClass, String],
scope: [:optional, NilClass, Set.new(["compact", nil])],
size: [:optional, NilClass, Set.new(["compact", nil])],
text: [:optional, NilClass, String],
title: [:optional, NilClass, String],
title_tag: [:optional, NilClass, Set.new(["h1", "h2", "h3", "h4", "h5", "h6"])],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%
variant = component.scope.present? ? component.scope : false
variant = component.size.present? ? component.size : false
title_tag = variant == "compact" ? "h2" : "h1"
if component.title_tag.present?
title_tag = component.title_tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ $-empty-state-icon-compact-size: rem(56px);
.sage-empty-state {
@include sage-grid-panel();

gap: sage-spacing(sm);
margin-inline-start: auto;
margin-inline-end: auto;
max-width: sage-container(md);
text-align: center;
justify-items: center;
gap: sage-spacing(sm);
}

.sage-empty-state--center {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
}
}

.sage-icon-card--gradient {
background-image: linear-gradient(180deg, var(--color-gradient-top) 0%, var(--color-gradient-bottom) 100%)
}
.sage-icon-card--round {
border-radius: sage-border(radius-round);
}
12 changes: 6 additions & 6 deletions packages/sage-react/lib/EmptyState/EmptyState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import classnames from 'classnames';
import { SageTokens } from '../configs';
import { Button } from '../Button';
import { Icon } from '../Icon';
import { EMPTY_STATE_SCOPES } from './configs';
import { EMPTY_STATE_SIZES } from './configs';

export const EmptyState = ({
actions,
centerVertical,
children,
graphic,
icon,
scope,
size,
text,
title,
titleTag,
Expand All @@ -23,7 +23,7 @@ export const EmptyState = ({
'sage-empty-state',
{
'sage-empty-state--center': centerVertical,
[`sage-empty-state--${scope}`]: scope,
[`sage-empty-state--${size}`]: size,
},
);

Expand Down Expand Up @@ -84,15 +84,15 @@ export const EmptyState = ({
);
};

EmptyState.SCOPES = EMPTY_STATE_SCOPES;
EmptyState.SIZES = EMPTY_STATE_SIZES;

EmptyState.defaultProps = {
actions: null,
centerVertical: false,
children: null,
graphic: null,
icon: null,
scope: EmptyState.SCOPES.DEFAULT,
size: EmptyState.SIZES.DEFAULT,
text: null,
title: null,
titleTag: 'h2',
Expand All @@ -105,7 +105,7 @@ EmptyState.propTypes = {
children: PropTypes.node,
graphic: PropTypes.node,
icon: PropTypes.oneOf(Object.values(SageTokens.ICONS)),
scope: PropTypes.oneOf(Object.values(EmptyState.SCOPES)),
size: PropTypes.oneOf(Object.values(EmptyState.SIZES)),
text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
titleTag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
Expand Down
8 changes: 4 additions & 4 deletions packages/sage-react/lib/EmptyState/EmptyState.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
argTypes: {
...selectArgs({
icon: SageTokens.ICONS,
scope: EmptyState.SCOPES
size: EmptyState.SIZES
})
},
args: {
Expand All @@ -35,11 +35,11 @@ const Template = (args) => <EmptyState {...args} />;

export const Default = Template.bind({});

export const CompactScope = Template.bind({});
CompactScope.args = {
export const Compactsize = Template.bind({});
Compactsize.args = {
icon: null,
graphic: (<img src="//source.unsplash.com/random/530x500" alt="" />),
scope: EmptyState.SCOPES.PAGE,
size: EmptyState.SIZES.PAGE,
text: (
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Expand Down
2 changes: 1 addition & 1 deletion packages/sage-react/lib/EmptyState/configs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const EMPTY_STATE_SCOPES = {
export const EMPTY_STATE_SIZES = {
DEFAULT: null,
COMPACT: 'compact',
};

0 comments on commit 5eaf22f

Please sign in to comment.