Skip to content

Commit

Permalink
fix: user rows adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Dec 5, 2024
1 parent 4bf2b76 commit dcebd92
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 22 deletions.
16 changes: 8 additions & 8 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-05-10T12:25:45.620Z\n"
"PO-Revision-Date: 2023-05-10T12:25:45.620Z\n"
"POT-Creation-Date: 2024-12-04T17:00:46.379Z\n"
"PO-Revision-Date: 2024-12-04T17:00:46.380Z\n"

msgid "Untitled dashboard"
msgstr "Untitled dashboard"
Expand Down Expand Up @@ -478,12 +478,6 @@ msgstr "Yes, remove filters"
msgid "The dashboard couldn't be made available offline. Try again."
msgstr "The dashboard couldn't be made available offline. Try again."

msgid "Failed to unstar the dashboard"
msgstr "Failed to unstar the dashboard"

msgid "Failed to star the dashboard"
msgstr "Failed to star the dashboard"

msgid "Remove from offline storage"
msgstr "Remove from offline storage"

Expand Down Expand Up @@ -548,6 +542,12 @@ msgstr "Cannot unstar this dashboard while offline"
msgid "Cannot star this dashboard while offline"
msgstr "Cannot star this dashboard while offline"

msgid "Failed to unstar the dashboard"
msgstr "Failed to unstar the dashboard"

msgid "Failed to star the dashboard"
msgstr "Failed to star the dashboard"

msgid "Loading dashboard – {{name}}"
msgstr "Loading dashboard – {{name}}"

Expand Down
6 changes: 0 additions & 6 deletions src/components/DashboardsBar/__tests__/getRowsFromHeight.js

This file was deleted.

22 changes: 22 additions & 0 deletions src/components/DashboardsBar/__tests__/getRowsFromHeight.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getRowsFromHeight } from '../getRowsFromHeight.js'

test('getRowsFromHeight returns an integer', () => {
const res = getRowsFromHeight(100)
expect(Number.isInteger(res)).toBeTruthy()
})

const testCases = [
{ height: 0, rows: 0 },
{ height: 36, rows: 1 },
{ height: 100, rows: 3 },
{ height: 200, rows: 5 },
{ height: 300, rows: 8 },
{ height: 400, rows: 10 },
{ height: 500, rows: 13 },
]

testCases.forEach(({ height, rows }) => {
test(`getRowsFromHeight returns ${rows} for height ${height}`, () => {
expect(getRowsFromHeight(height)).toBe(rows)
})
})
18 changes: 12 additions & 6 deletions src/components/DashboardsBar/getRowsFromHeight.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
const ROW_HEIGHT = 32
const PADDING_TOP = 6
const SHOWMORE_BUTTON_HEIGHT = 0 // No longer shown under the chip area
/* ROW_HEIGHT is the height of a chip + the gap between chips.
But this isn't correct for the first or last row in the dashboards bar
because the gap is only applied between rows, not at the top or bottom.
So the first and last row are actually 3px shorter than the other rows, i.e. 35px
But in order to keep the calculation simple, we'll just use 38px for all rows, while
subtracting 3px from PADDING_TOP (which is actually 6px)
*/
const ROW_HEIGHT = 38 // 32px chip + 6px gap
const PADDING_TOP = 3

export const getRowsFromHeight = (height) => {
return Math.round(
(height - SHOWMORE_BUTTON_HEIGHT - PADDING_TOP) / ROW_HEIGHT
)
return Math.abs(Math.round(
(height - PADDING_TOP) / ROW_HEIGHT
))
}
4 changes: 2 additions & 2 deletions src/components/styles/App.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:root {
/* control bar variables */
--user-rows-count: 1;
--controlbar-padding: 8px;
--row-height: 36px;
--controlbar-padding: 3px;
--row-height: 38px;
--min-rows-height: calc(
var(--controlbar-padding) + (1 * var(--row-height))
);
Expand Down

0 comments on commit dcebd92

Please sign in to comment.