Skip to content

Commit

Permalink
fix: fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Oct 28, 2024
1 parent 4f5dd85 commit fae9bad
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
12 changes: 6 additions & 6 deletions app/lib/utils/contrast-color.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export function contrastColor(color: string) {
export const contrastColor = (color: string) => {
return luma(color) >= 165 ? '#444' : '#fff'
}
function luma(color: string | Array<number>) {
const luma = (color: string | Array<number>) => {
// color can be a hx string or an array of RGB values 0-255
var rgb = typeof color === 'string' ? hexToRGBArray(color) : color
const rgb = typeof color === 'string' ? hexToRGBArray(color) : color
return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2] // SMPTE C, Rec. 709 weightings
}
function hexToRGBArray(color: string) {
const hexToRGBArray = (color: string) => {
if (color.length === 3)
color =
color.charAt(0) +
Expand All @@ -16,7 +16,7 @@ function hexToRGBArray(color: string) {
color.charAt(2) +
color.charAt(2)
else if (color.length !== 6) throw 'Invalid hex color: ' + color
var rgb = []
for (var i = 0; i <= 2; i++) rgb[i] = parseInt(color.substr(i * 2, 2), 16)
const rgb = []
for (let i = 0; i <= 2; i++) rgb[i] = parseInt(color.substr(i * 2, 2), 16)
return rgb
}
9 changes: 5 additions & 4 deletions app/routes/app.documents.$document.attach.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {ensureUser} from '~/lib/utils/ensure-user'
import {getPrisma} from '~/lib/prisma.server'
import {pageTitle} from '~/lib/utils/page-title'
import {Input} from '~/lib/components/input'
import {Button} from '~/lib/components/button'
import {getUploadMetaData} from '~/lib/utils/upload-handler.server'
import {getUploadHandler} from '~/lib/utils/upload-handler.server'
import {AButton} from '~/lib/components/button'
import {Button, AButton} from '~/lib/components/button'
import {
getUploadMetaData,
getUploadHandler
} from '~/lib/utils/upload-handler.server'

export type Attachment = {
uri: string
Expand Down
2 changes: 1 addition & 1 deletion app/routes/app.system.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const System = () => {
<Label>
Site Name
<Input name="site-name" defaultValue={settings['site-name']} />
<HelperText>This defaults to "Net Doc"</HelperText>
<HelperText>This defaults to &quot;Net Doc&quot;</HelperText>
</Label>
<Label>
Site Color
Expand Down
2 changes: 0 additions & 2 deletions app/routes/app_.login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {createTimings} from '~/lib/utils/timings.server'

import {getSession, commitSession} from '~/lib/cookies'

import {pageTitle} from '~/lib/utils/page-title'

export const action = async ({request}: ActionFunctionArgs) => {
const {time, getHeader, headers} = createTimings()

Expand Down
17 changes: 16 additions & 1 deletion tests/unit/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,22 @@ describe('Timing', () => {

describe('Page Title', () => {
test('should generate a page title', () => {
expect(pageTitle('Test')).toBe('Net Doc / Test')
expect(
pageTitle(
[
{
pathname: '/app',
data: {
settings: {'site-name': 'Net Doc'}
},
id: '',
params: {},
meta: []
}
],
'Test'
)
).toBe('Net Doc / Test')
})
})

Expand Down

0 comments on commit fae9bad

Please sign in to comment.