Skip to content

Commit

Permalink
Merge dev to master (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
sc-illiakovalenko authored Apr 1, 2020
1 parent 56595f8 commit 26edbad
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 75 deletions.
4 changes: 2 additions & 2 deletions packages/sitecore-jss-cli/src/scripts/deploy.files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const builder = {
type: 'boolean',
describe:
'If true, no build task is invoked and any existing build artifacts at the source path are deployed.',
default: 'false',
default: false,
},
buildTaskName: {
requiresArg: false,
Expand All @@ -50,7 +50,7 @@ export const builder = {
type: 'boolean',
describe:
'Whether to delete all existing items in the destination before copying new artifacts.',
default: 'false',
default: false,
},
};

Expand Down
4 changes: 2 additions & 2 deletions packages/sitecore-jss-forms/src/FormField.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HtmlFormField } from './HtmlFormField';
import { InputViewModel, TitleFieldViewModel, ViewModel } from './ViewModel';
import { InputViewModel, TitleFieldViewModel, ViewModel, FieldViewModel } from './ViewModel';

export interface FormField<TViewModel extends ViewModel = ViewModel> {
model: TViewModel;
Expand Down Expand Up @@ -29,7 +29,7 @@ export function instanceOfButtonFormField(object: FormField): object is ButtonFo
return 'buttonField' in object;
}

export interface FormFieldSection extends FormField<ViewModel> {
export interface FormFieldSection extends FormField<FieldViewModel> {
fields: FormField[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Section: React.FunctionComponent<FieldProps<FormFieldSection>> = ({
field,
fieldFactory,
}) => (
<fieldset>
<fieldset className={field.model.cssClass}>
{field.fields.map(fieldFactory)}
</fieldset>
);
Expand Down
29 changes: 29 additions & 0 deletions packages/sitecore-jss-react/src/components/Image.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,35 @@ describe('<Image />', () => {
});
});

describe('with responsive image object', () => {
const props = {
media: {
src: '/assets/img/test0.png',
},
srcSet: [{ mw: 100 }, { mw: 300 }],
sizes: '(min-width: 960px) 300px, 100px',
id: 'some-id',
className: 'the-dude-abides',
};

const rendered = mount(<Image {...props} />).find('img');

it('should render <img /> with needed img tags', () => {
expect(rendered).to.have.length(1);
expect(rendered.prop('src')).to.equal(props.media.src);
expect(rendered.prop('srcSet')).to.equal('/assets/img/test0.png?mw=100 100w, /assets/img/test0.png?mw=300 300w');
expect(rendered.prop('sizes')).to.equal('(min-width: 960px) 300px, 100px');
});

it('should render <img /> with non-media props', () => {
expect(rendered.prop('id')).to.equal(props.id);
});

it('should render <img /> with style and className props', () => {
expect(rendered.prop('className')).to.eql(props.className);
});
});

describe('with "value" property value', () => {
const props = {
media: { value: { src: '/assets/img/test0.png', alt: 'my image' } },
Expand Down
6 changes: 3 additions & 3 deletions packages/sitecore-jss-react/src/components/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ const getImageAttrs = (
if (srcSet) {
// replace with HTML-formatted srcset, including updated image URLs
newAttrs.srcSet = mediaApi.getSrcSet(resolvedSrc, srcSet, imageParams);
} else {
newAttrs.src = resolvedSrc;
}
// always output original src as fallback for older browsers
newAttrs.src = resolvedSrc;
return newAttrs;
};

Expand Down Expand Up @@ -176,4 +176,4 @@ Image.defaultProps = {
editable: true,
};

Image.displayName = 'Image';
Image.displayName = 'Image';
Loading

0 comments on commit 26edbad

Please sign in to comment.