Skip to content

Commit

Permalink
Merge branch 'main' into feat/search-component
Browse files Browse the repository at this point in the history
  • Loading branch information
matthprost committed Jun 18, 2024
2 parents baccd4b + 10e7a83 commit 97a7ebd
Show file tree
Hide file tree
Showing 19 changed files with 625 additions and 76 deletions.
7 changes: 7 additions & 0 deletions .changeset/olive-plants-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ultraviolet/form": patch
"@ultraviolet/plus": patch
"@ultraviolet/ui": patch
---

`<NumberInputV2 />`: possibility to hide controls
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- run: pnpm run build
- run: pnpm install
- run: pnpm run test:unit:coverage
- uses: codecov/codecov-action@v4.4.1
- uses: codecov/codecov-action@v4.5.0
with:
# files: packages/**/coverage/cobertura-coverage.xmls
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ exports[`NumberInputFieldV2 > should render correctly 1`] = `
cursor: not-allowed;
}
.emotion-2[data-controls='false']>.emotion-10 {
border-width: 0;
}
.emotion-4 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -275,6 +279,10 @@ exports[`NumberInputFieldV2 > should render correctly 1`] = `
color: #727683;
}
.emotion-13[data-controls='false'] {
text-align: left;
}
<div
data-testid="testing"
>
Expand All @@ -287,6 +295,7 @@ exports[`NumberInputFieldV2 > should render correctly 1`] = `
<div>
<div
class="emotion-2 emotion-3"
data-controls="true"
data-disabled="false"
data-error="false"
data-success="false"
Expand Down Expand Up @@ -317,6 +326,7 @@ exports[`NumberInputFieldV2 > should render correctly 1`] = `
>
<input
class="emotion-13 emotion-14"
data-controls="true"
data-has-unit="false"
data-size="large"
id=":r0:"
Expand Down Expand Up @@ -429,6 +439,10 @@ exports[`NumberInputFieldV2 > should render correctly disabled 1`] = `
cursor: not-allowed;
}
.emotion-2[data-controls='false']>.emotion-10 {
border-width: 0;
}
.emotion-4 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -622,6 +636,10 @@ exports[`NumberInputFieldV2 > should render correctly disabled 1`] = `
color: #727683;
}
.emotion-13[data-controls='false'] {
text-align: left;
}
<div
data-testid="testing"
>
Expand All @@ -634,6 +652,7 @@ exports[`NumberInputFieldV2 > should render correctly disabled 1`] = `
<div>
<div
class="emotion-2 emotion-3"
data-controls="true"
data-disabled="true"
data-error="false"
data-success="false"
Expand Down Expand Up @@ -666,6 +685,7 @@ exports[`NumberInputFieldV2 > should render correctly disabled 1`] = `
<input
aria-label="Number Input"
class="emotion-13 emotion-14"
data-controls="true"
data-has-unit="false"
data-size="large"
disabled=""
Expand Down
3 changes: 3 additions & 0 deletions packages/form/src/components/NumberInputFieldV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type NumberInputV2Props<
| 'readOnly'
| 'min'
| 'max'
| 'controls'
>
> & {
className?: string
Expand Down Expand Up @@ -64,6 +65,7 @@ export const NumberInputFieldV2 = <
success,
helper,
rules,
controls = true,
'aria-label': ariaLabel,
'data-testid': dataTestId,
required,
Expand Down Expand Up @@ -119,6 +121,7 @@ export const NumberInputFieldV2 = <
autoFocus={autoFocus}
readOnly={readOnly}
required={required}
controls={controls}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type NumberInputProps = {
getAmountValue?: (amount?: number | null) => void
minValue?: number
maxValue?: number
controls?: boolean
}

export const NumberInput = ({
Expand All @@ -18,6 +19,7 @@ export const NumberInput = ({
maxValue = 100,
getAmountValue,
itemCallback,
controls = true,
}: NumberInputProps) => {
const { isOverlay } = useOverlay()
const [value, setValue] = useState<number | undefined | null>(amount)
Expand All @@ -41,6 +43,7 @@ export const NumberInput = ({
getAmountValue?.(newValue)
}}
value={value}
controls={controls}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ Design.args = {

Design.parameters = {
docs: {
storyDescription:
'There are multiple design prop that you can change to show each item differently.<br/>' +
'- `tabulation` can be used to add padding left on label of the item<br/>' +
'- `noPrice` can be used to remove price of the item<br/>' +
'- `noBorder` can be used to removed bottom border of the item<br/>' +
'- `hideFromOverlay` will hide the item from overlay<br/>' +
'- `shouldBeHidden` will hide the item from overlay on small screens<br/>',
description: {
story:
'There are multiple design prop that you can change to show each item differently.<br/>' +
'- `tabulation` can be used to add padding left on label of the item<br/>' +
'- `noPrice` can be used to remove price of the item<br/>' +
'- `noBorder` can be used to removed bottom border of the item<br/>' +
'- `hideFromOverlay` will hide the item from overlay<br/>' +
'- `shouldBeHidden` will hide the item from overlay on small screens<br/>',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ GlobalDiscount.args = {

GlobalDiscount.parameters = {
docs: {
storyDescription:
'A global or local discount can be applied to your total using `discount` prop that take a value between 0 and 1 (ex: 0.5 equivalent to 50% discount).<br/>' +
'To make it global just add the prop `discount` to `EstimateCost`. Also you can use the prop `isBeta` to show a beta badge with the discount value.',
description: {
story:
'A global or local discount can be applied to your total using `discount` prop that take a value between 0 and 1 (ex: 0.5 equivalent to 50% discount).<br/>' +
'To make it global just add the prop `discount` to `EstimateCost`. Also you can use the prop `isBeta` to show a beta badge with the discount value.',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Item.args = {

Item.parameters = {
docs: {
storyDescription:
'Items are required to build and display your EstimateCost. In fact, `EstimateCost.Item` ' +
'is use to display each items of your total price. You can define a bunch of parameters such as `label`, `subLabel`, `price`, ...',
description: {
story:
'Items are required to build and display your EstimateCost. In fact, `EstimateCost.Item` ' +
'is use to display each items of your total price. You can define a bunch of parameters such as `label`, `subLabel`, `price`, ...',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ LocalDiscount.args = {

LocalDiscount.parameters = {
docs: {
storyDescription:
'To make it local to one item add prop `discount` to the desired item `EstimateCost.Item`',
description: {
story:
'To make it local to one item add prop `discount` to the desired item `EstimateCost.Item`',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ NumberInput.args = {

NumberInput.parameters = {
docs: {
storyDescription:
'Item NumberInput is an interactive input. It allows user to change the amount of an item and see how much it will cost. <br/>' +
'The component `EstimateCost.Item` include a prop called `amountFree` as number. This number is deducted to NumberInput value ' +
'(check example with 2 million queries free).' +
'<br/><br/>' +
'You can get value of the amount set in NumberInput by using `getAmountValue` prop.',
description: {
story:
'Item NumberInput is an interactive input. It allows user to change the amount of an item and see how much it will cost. <br/>' +
'The component `EstimateCost.Item` include a prop called `amountFree` as number. This number is deducted to NumberInput value ' +
'(check example with 2 million queries free).' +
'<br/><br/>' +
'You can get value of the amount set in NumberInput by using `getAmountValue` prop. <br/>You can hide controls in NumberInput by using `controls` prop.',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Region.args = {

Region.parameters = {
docs: {
storyDescription:
'Region is a composed Item that will display a specific region.',
description: {
story: 'Region is a composed Item that will display a specific region.',
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ Unit.args = {

Unit.parameters = {
docs: {
storyDescription:
'Item unit is an interactive input. It allows customers to change the value to see how much it will cost. <br/>' +
'The component `EstimateCost.Item` include a prop called `amountFree` as number. This number is deducted to NumberInput ' +
'value (check example with 50 GB Free).' +
'<br/><br/>' +
'You can get value of the amount set in NumberInput by using `getAmountValue` prop.',
description: {
story:
'Item unit is an interactive input. It allows customers to change the value to see how much it will cost. <br/>' +
'The component `EstimateCost.Item` include a prop called `amountFree` as number. This number is deducted to NumberInput ' +
'value (check example with 50 GB Free).' +
'<br/><br/>' +
'You can get value of the amount set in NumberInput by using `getAmountValue` prop.',
},
},
}
Loading

0 comments on commit 97a7ebd

Please sign in to comment.