mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 14:35:03 +00:00
feat: Moved Workspace Selector to the Titlebar of the window. (#6319)
* refactor: update sidebar components and styles, replace TitleBar with SidebarHeader, and enhance collections search functionality * refactor: improve event listener management in AppTitleBar and clean up SidebarHeader styles * fix: ensure safe access to layout preferences in AppTitleBar and set default order in SidebarHeader * refactor: centralize toTitleCase utility and remove redundant implementations in AppTitleBar and WorkspaceSelector * feat: enhance accessibility and testing for sidebar and devtools toggle buttons in AppTitleBar * chore: quick fix on a flaky test --------- Co-authored-by: Bijin A B <bijin@usebruno.com>
This commit is contained in:
@@ -338,3 +338,23 @@ export const prettifyJsonString = (jsonDataString) => {
|
||||
}
|
||||
return jsonDataString;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the given string value converted to title case.
|
||||
* - If the value is falsy, returns an empty string.
|
||||
* - Special-case: if the value is 'default', returns 'Default'.
|
||||
* - Otherwise, splits the string on whitespace, hyphens, or underscores,
|
||||
* uppercases the first letter of each word, and lowercases the rest.
|
||||
*
|
||||
* @param {string} str - The input string to convert.
|
||||
* @returns {string} - The converted title-case string.
|
||||
*/
|
||||
|
||||
export const toTitleCase = (str) => {
|
||||
if (!str) return '';
|
||||
if (str === 'default') return 'Default';
|
||||
return str
|
||||
.split(/[\s-_]+/)
|
||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user