Skip to content

Commit

Permalink
im taking my win
Browse files Browse the repository at this point in the history
  • Loading branch information
voxxal committed Jan 30, 2024
1 parent d6350c2 commit 5b59e10
Show file tree
Hide file tree
Showing 10 changed files with 846 additions and 561 deletions.
2 changes: 1 addition & 1 deletion client/src/api/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getOwnItems = async () => {
}
return {
data: {
equipped: data.equippedItems.map((item) => item.id),
equipped: Object.values(data.equippedItems).map((item) => item.id),
items: data.items
}
}
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Header({ classes, paths }) {
}, [])

return (
<div class="tab-container tabs-center">
<div class={`tab-container tabs-center ${classes.root}`}>
<ul class={classes.list}>
{paths.map(({ props: { path, name } }) => (
<Match key={name} path={path}>
Expand All @@ -49,6 +49,10 @@ function Header({ classes, paths }) {

export default withStyles(
{
root: {
background: '#111 !important',
zIndex: 30
},
link: {
'&:focus': {
boxShadow: 'none',
Expand Down
43 changes: 36 additions & 7 deletions client/src/components/item.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import withStyles from '../components/jss'
import { useState, useCallback, useRef } from 'preact/hooks'
import { useState, useCallback, useRef, useMemo } from 'preact/hooks'

Check failure on line 2 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

'useRef' is defined but never used

import { submitFlag, getSolves } from '../api/challenges'

Check failure on line 4 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

'submitFlag' is defined but never used

Check failure on line 4 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

'getSolves' is defined but never used
import { useToast } from './toast'
import SolvesDialog from './solves-dialog'

Check failure on line 6 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

'SolvesDialog' is defined but never used
import Markdown from './markdown'
import { buyItem, equipItem } from '../api/items'
import { addFont } from '../util/items'

const ExternalLink = (props) => <a {...props} target="_blank" />

Check failure on line 11 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

Unexpected usage of doublequote

Expand All @@ -20,6 +21,29 @@ const Problem = ({ classes, item, owned, equipped, setItemStatus }) => {

const [error, setError] = useState(undefined)
const hasError = error !== undefined
const Preview = useMemo(() => {
const init = async () => {
switch (item.type) {
case 'font':
addFont(item.id, item.resourceUrl);
break
}
}
init()

switch (item.type) {
case 'font':
return () => (

Check warning on line 36 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

Component definition is missing display name
<p style={{ fontFamily: `font-${item.id}` }} class={`${classes.preview}`}>
This is how text will look on your profile
</p>
)
case 'background':
return () => (

Check warning on line 42 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

Component definition is missing display name
<img src={item.resourceUrl} class={`${classes.preview} ${classes.previewImage}`}/>
)
}
}, [item])

Check warning on line 46 in client/src/components/item.js

View workflow job for this annotation

GitHub Actions / lint (12)

React Hook useMemo has missing dependencies: 'classes.preview' and 'classes.previewImage'. Either include them or remove the dependency array

const handleSubmit = useCallback(
(e) => {
Expand All @@ -29,7 +53,7 @@ const Problem = ({ classes, item, owned, equipped, setItemStatus }) => {
if (error === undefined) {
toast({ body: 'Item successfuly bought!' })

setItemStatus(item.id, "BUY")
setItemStatus(item.id, 'BUY')
} else {
toast({ body: error, type: 'error' })
}
Expand Down Expand Up @@ -67,11 +91,7 @@ const Problem = ({ classes, item, owned, equipped, setItemStatus }) => {
<div class="frame__subtitle u-no-margin">{item.type}</div>
</div>
<div class="col-6 u-no-padding u-text-right">
<div
class={`${classes.points}`}
>
{item.type}
</div>
<div class={`${classes.points}`}>{item.price} chips</div>
</div>
</div>

Expand All @@ -84,6 +104,8 @@ const Problem = ({ classes, item, owned, equipped, setItemStatus }) => {
content={item.description}
components={markdownComponents}
/>
<h6>Preview</h6>
{Preview && <Preview />}
</div>

<button
Expand Down Expand Up @@ -158,6 +180,13 @@ export default withStyles(
'&:hover': {
background: '#222'
}
},
preview: {
fontSize: '1.5rem !important',
marginTop: '0.5rem'
},
previewImage: {
aspectRatio: '16 / 9'
}
},
Problem
Expand Down
7 changes: 4 additions & 3 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ export default withStyles({
minHeight: '100%',
background: '#111',
color: '#fff',
'& *:not(code):not(pre)': {
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Noto Sans", "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important'
},
// SCREW THE CONCEPQUNECESk
// '& *:not(code):not(pre)': {
// fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Noto Sans", "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"!important'
// },
'& pre.code': {
padding: '10px',
background: 'var(--cirrus-code-bg)',
Expand Down
Loading

0 comments on commit 5b59e10

Please sign in to comment.