Skip to content

Commit 1728188

Browse files
committed
feat: add size variant for search bar
1 parent 9a95692 commit 1728188

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.8-beta-11",
3+
"version": "0.1.8-beta-12",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/SearchBar/SearchBar.component.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
*/
1616

1717
import { ChangeEvent, useCallback, useRef, useState, KeyboardEvent, useEffect } from 'react'
18+
import { ComponentSizeType } from '@Shared/constants'
1819
import { ReactComponent as Search } from '@Icons/ic-search.svg'
1920
import { ReactComponent as Clear } from '@Icons/ic-error-cross.svg'
2021
import { SearchBarProps } from './types'
2122
import './searchBar.scss'
2223
import { debounce } from '../Helper'
24+
import { getSearchBarHeightFromSize } from './utils'
2325

2426
/**
2527
* Generic search input component with support for enter based and debounced search
@@ -65,6 +67,7 @@ const SearchBar = ({
6567
debounceTimeout = 300,
6668
dataTestId = 'search-bar',
6769
noBackgroundAndBorder = false,
70+
size = ComponentSizeType.medium,
6871
}: SearchBarProps) => {
6972
const [showClearButton, setShowClearButton] = useState(!!initialSearchText)
7073
const inputRef = useRef<HTMLInputElement>()
@@ -116,7 +119,7 @@ const SearchBar = ({
116119
return (
117120
<div className={containerClassName}>
118121
<div
119-
className={`search-bar ${noBackgroundAndBorder ? 'dc__no-border dc__no-background dc__hover-n50' : 'bc-n50 en-2 dc__hover-border-n300'} focus-within-border-b5 dc__block w-100 min-w-200 dc__position-rel br-4 bw-1 h-32`}
122+
className={`search-bar ${noBackgroundAndBorder ? 'dc__no-border dc__no-background dc__hover-n50' : 'bc-n50 en-2 dc__hover-border-n300'} focus-within-border-b5 dc__block w-100 min-w-200 dc__position-rel br-4 bw-1 ${getSearchBarHeightFromSize(size)}`}
120123
>
121124
<Search className="search-bar__icon dc__position-abs icon-color-n6 icon-dim-16" />
122125
<input

src/Common/SearchBar/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { ComponentSizeType } from '@Shared/constants'
18+
1719
export interface SearchBarProps {
1820
/**
1921
* Initial search text
@@ -55,4 +57,10 @@ export interface SearchBarProps {
5557
* Hide the background and border of the search
5658
*/
5759
noBackgroundAndBorder?: boolean
60+
/**
61+
* Height of the searchbar
62+
*
63+
* @default 'ComponentSizeType.medium'
64+
*/
65+
size?: ComponentSizeType.medium | ComponentSizeType.large
5866
}

src/Common/SearchBar/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ComponentSizeType } from '@Shared/constants'
2+
import { SearchBarProps } from './types'
3+
4+
export const getSearchBarHeightFromSize = (size: SearchBarProps['size']): string => {
5+
switch (size) {
6+
case ComponentSizeType.large:
7+
return 'h-36'
8+
default:
9+
return 'h-32'
10+
}
11+
}

src/Shared/Components/CICDHistory/LogStageAccordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const LogStageAccordion = ({
3333
<button
3434
className={`flexbox dc__transparent dc__content-space py-6 px-8 br-4 dc__align-items-center dc__select-text logs-renderer__stage-accordion ${
3535
isOpen ? 'logs-renderer__stage-accordion--open-stage' : ''
36-
} dc__position-sticky dc__zi-1 dc__top-40`}
36+
} dc__position-sticky dc__zi-1 dc__top-44`}
3737
type="button"
3838
role="tab"
3939
onClick={handleAccordionToggle}

src/Shared/Components/CICDHistory/LogsRenderer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { useParams } from 'react-router'
1818
import { useEffect, useRef, useState } from 'react'
1919
import AnsiUp from 'ansi_up'
2020
import DOMPurify from 'dompurify'
21-
import { ANSI_UP_REGEX } from '@Shared/constants'
21+
import { ANSI_UP_REGEX, ComponentSizeType } from '@Shared/constants'
2222
import {
2323
Progressing,
2424
Host,
@@ -200,7 +200,7 @@ export const LogsRenderer = ({
200200
acc.push(
201201
part.replace(
202202
new RegExp(targetSearchKey, 'g'),
203-
`\x1B[48;2;197;141;54m${targetSearchKey}\x1B[0m${index > 0 ? availableEscapeCodes[index - 1] : ''}`,
203+
`\x1B[0m\x1B[48;2;197;141;54m${targetSearchKey}\x1B[0m${index > 0 ? availableEscapeCodes[index - 1] : ''}`,
204204
),
205205
)
206206
if (part.includes(targetSearchKey)) {
@@ -414,6 +414,7 @@ export const LogsRenderer = ({
414414
}}
415415
handleEnter={handleSearchEnter}
416416
initialSearchText={searchKey}
417+
size={ComponentSizeType.large}
417418
/>
418419
</div>
419420
</div>

0 commit comments

Comments
 (0)