Skip to content

Commit

Permalink
Merge pull request #21 from vtex-apps/improvement/element-ids
Browse files Browse the repository at this point in the history
Improves id attribution
  • Loading branch information
jeffersontuc authored Oct 23, 2019
2 parents ceb539d + a7a6713 commit 36f5c46
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- Improvements to `id` attribution of some elements.

## [0.11.3] - 2019-10-23

### Added
Expand Down
2 changes: 1 addition & 1 deletion react/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Image: FunctionComponent = () => {

return (
<div
id={`${item.id}-image`}
id={`image-${item.id}`}
className={opaque(item.availability)}
style={{ minWidth: '96px' }}
>
Expand Down
4 changes: 2 additions & 2 deletions react/Price.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const Price: StorefrontFunctionComponent<TextAlignProp> = ({ textAlign }) => {
<div>
{item.listPrice !== item.price && (
<div
id={`${item.id}-list-price`}
id={`list-price-${item.id}`}
className="c-muted-1 strike t-mini mb2"
>
<FormattedCurrency value={(item.listPrice * item.quantity) / 100} />
</div>
)}
<div id={`${item.id}-price`} className="div fw6 fw5-m">
<div id={`price-${item.id}`} className="div fw6 fw5-m">
<FormattedPrice value={(item.sellingPrice * item.quantity) / 100} />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion react/ProductBrand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ProductBrand: FunctionComponent = () => {

return (
<div
id={`${item.id}-brand-name`}
id={`brand-name-${item.id}`}
className={`ttu f7 fw6 c-muted-1 fw5-m ${opaque(item.availability)}`}
>
{item.additionalInfo.brandName}
Expand Down
2 changes: 1 addition & 1 deletion react/ProductName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ProductName: FunctionComponent = () => {

return (
<a
id={`${item.id}-name`}
id={`name-${item.id}`}
className={`c-on-base t-title lh-copy fw6 no-underline fw5-m ${opaque(
item.availability
)}`}
Expand Down
2 changes: 1 addition & 1 deletion react/ProductVariations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ProductVariations: FunctionComponent = () => {
{item.skuSpecifications.map((spec: SKUSpecification) => {
return (
<div
id={`${item.id}-${spec.fieldName}-specification`}
id={`specification-${item.id}-${spec.fieldName}`}
key={spec.fieldName}
>
{`${spec.fieldName}: ${spec.fieldValues.join(', ')}`}
Expand Down
2 changes: 1 addition & 1 deletion react/QuantitySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const QuantitySelector: FunctionComponent = () => {

return (
<div
id={`${item.id}-selector`}
className={`${opaque(item.availability)} ${styles.quantity} ${
styles.quantitySelector
}`}
>
<Selector
id={item.id}
value={item.quantity}
maxValue={MAX_ITEM_QUANTITY}
onChange={onQuantityChange}
Expand Down
1 change: 1 addition & 0 deletions react/UnitPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const UnitPrice: StorefrontFunctionComponent<TextAlignProp> = ({

return item.quantity > 1 && item.sellingPrice > 0 ? (
<div
id={`unit-price-${item.id}`}
className={`t-mini c-muted-1 lh-title ${styles.quantity} ${opaque(
item.availability
)} ${parseTextAlign(textAlign)}`}
Expand Down
6 changes: 6 additions & 0 deletions react/components/QuantitySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum SelectorType {
}

interface Props {
id: string
value: number
maxValue: number
onChange: (value: number) => void
Expand Down Expand Up @@ -67,6 +68,7 @@ const getDropdownOptions = (maxValue: number, intl: InjectedIntl) => {
}

const QuantitySelector: FunctionComponent<Props & InjectedIntlProps> = ({
id,
value,
maxValue,
onChange,
Expand Down Expand Up @@ -129,6 +131,7 @@ const QuantitySelector: FunctionComponent<Props & InjectedIntlProps> = ({
<div>
<div className="dn-m">
<Dropdown
id={`quantity-dropdown-mobile-${id}`}
options={dropdownOptions}
size="small"
value={normalizedValue}
Expand All @@ -139,6 +142,7 @@ const QuantitySelector: FunctionComponent<Props & InjectedIntlProps> = ({
</div>
<div className="dn db-m">
<Dropdown
id={`quantity-dropdown-${id}`}
options={dropdownOptions}
value={normalizedValue}
onChange={(event: any) => handleDropdownChange(event.target.value)}
Expand All @@ -153,6 +157,7 @@ const QuantitySelector: FunctionComponent<Props & InjectedIntlProps> = ({
<div>
<div className="dn-m">
<Input
id={`quantity-input-mobile-${id}`}
size="small"
value={curDisplayValue}
maxLength={MAX_INPUT_LENGTH}
Expand All @@ -165,6 +170,7 @@ const QuantitySelector: FunctionComponent<Props & InjectedIntlProps> = ({
</div>
<div className="dn db-m">
<Input
id={`quantity-input-${id}`}
value={curDisplayValue}
maxLength={MAX_INPUT_LENGTH}
onChange={(event: any) => handleInputChange(event.target.value)}
Expand Down

0 comments on commit 36f5c46

Please sign in to comment.