Skip to content

Commit

Permalink
Merge pull request #10 from TereseBo/update_info
Browse files Browse the repository at this point in the history
Structural changes to folderstructure
  • Loading branch information
TereseBo authored Mar 28, 2024
2 parents 9846768 + 365058c commit d933981
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/components/draft/draftoptions/DbOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DbLoadWeave } from '@/app/components/draft/dbhandler/DbLoadWeave'
import { DbSaveWeave } from '@/app/components/draft/dbhandler/DbSaveWeave'
import { DbLoadWeave } from '@/app/components/draft/draftoptions/dbhandler/DbLoadWeave'
import { DbSaveWeave } from '@/app/components/draft/draftoptions/dbhandler/DbSaveWeave'
export function DbOptions() {

return (
Expand Down
4 changes: 2 additions & 2 deletions app/components/draft/draftoptions/DraftSelection.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//This component renders a list of drafts from the DB, including a generated preview.
import './draftselection.scss' //The styling is heavy on this component in order to render as desired

import { useContext} from 'react'
import { useContext } from 'react'

import { DraftPreview } from '@/app/components/draft/dbhandler/DraftPreview'
import { DraftPreview } from '@/app/components/draft/draftoptions/dbhandler/DraftPreview'
import { WeaveContext } from '@/app/resources/contexts/weavecontext'
import { DraftList } from '@/app/resources/types/dbdocuments'

Expand Down
4 changes: 2 additions & 2 deletions app/components/draft/draftoptions/FileOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Downloadweave } from '@/app/components/draft/filehandler/Downloadweave'
import { Uploadweave } from '@/app/components/draft/filehandler/Uploadweave'
import { Downloadweave } from '@/app/components/draft/draftoptions/filehandler/Downloadweave'
import { Uploadweave } from '@/app/components/draft/draftoptions/filehandler/Uploadweave'
export function FileOptions() {

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useAuth } from '@clerk/nextjs'

import { DraftList } from '@/app/resources/types/dbdocuments'

import { DraftSelection } from '../draftoptions/DraftSelection'
import { DraftSelection } from '../DraftSelection'

export function DbLoadWeave() {

Expand Down Expand Up @@ -37,7 +37,7 @@ export function DbLoadWeave() {

return (
<>
{visibleDraftList ? <DraftSelection userDrafts={userDrafts} setVisibility={setVisibleDraftList}/> : null}
{visibleDraftList ? <DraftSelection userDrafts={userDrafts} setVisibility={setVisibleDraftList} /> : null}

<button id="uploadButton" onClick={collectUserWeaves}>Load
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import { useContext } from 'react'
import { useAuth } from '@clerk/nextjs'

import { createWeaveObject } from '@/app/components/draft/filehandler/functions/get/createWeaveObject'
import { createWeaveObject } from '@/app/components/draft/weaveObjHandler/get/createWeaveObject'
import { WeaveContext } from '@/app/resources/contexts/weavecontext'

export function DbSaveWeave() {
const { treadleGrid, tieUpGrid, warpGrid } = useContext(WeaveContext) as WeaveContextType

//TODO: Add validation to ensure empty draft is not saved
//TODO: Add validation to ensure empty draft is not saved

const { userId } = useAuth()

Expand All @@ -27,9 +27,9 @@ export function DbSaveWeave() {
}).then(function (response) {
console.log(response)
if (response.status == 201) {
console.log('sucsess', response)
}else{
alert('Ops, the draft could not be saved')
alert('Draft saved!')
} else {
alert('Ops, the draft could not be saved')
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import './draftpreview.scss';
import { useEffect, useState } from 'react'

import { Grid } from '@/app/components/draft/draft/Grid'
import { readWeaveObject } from '@/app/components/draft/filehandler/functions/set/readWeaveObject'
import { readWeaveObject } from '@/app/components/draft/weaveObjHandler/set/readWeaveObject'


export function DraftPreview(params:{weaveObj:WeaveObject}) {
const [previewGrid, setPreviewGrid] = useState<grid>(new Array(10).fill(new Array(10).fill('', 0)))
const {weaveObj}=params
export function DraftPreview(params: { weaveObj: WeaveObject }) {

const [previewGrid, setPreviewGrid] = useState<grid>(new Array(10).fill(new Array(10).fill('', 0)))
const { weaveObj } = params

useEffect(() => {
//Create grids for reading the weave¨
let shafts= weaveObj.shafts.count || 0
let shafts = weaveObj.shafts.count || 0
let newGrids = readWeaveObject(params.weaveObj)

//Trim since preview cant contain the full width
let shortTreadleGrid= newGrids.treadleGrid.slice(-11,-1)
let shortWarpGrid= newGrids.warpGrid.map(row=>{return row.slice(-11,-1)})
let tieUpGrid=newGrids.tieupGrid
let shortTreadleGrid = newGrids.treadleGrid.slice(-11, -1)
let shortWarpGrid = newGrids.warpGrid.map(row => { return row.slice(-11, -1) })
let tieUpGrid = newGrids.tieupGrid

//Returns the color if present for the beat
function getWeftColor(y: number) {
Expand Down Expand Up @@ -112,7 +112,7 @@ export function DraftPreview(params:{weaveObj:WeaveObject}) {

return (
<div className="preview-container">
<Grid content={previewGrid} type='preview' />
<Grid content={previewGrid} type='preview' />
</div>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link'

import { WeaveContext } from '@/app/resources/contexts/weavecontext'

import { createWeaveObject } from './functions/get/createWeaveObject'
import { createWeaveObject } from '../../weaveObjHandler/get/createWeaveObject'

export function Downloadweave() {
const { treadleGrid, tieUpGrid, warpGrid } = useContext(WeaveContext) as WeaveContextType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useContext, useState } from 'react'
import { WeaveContext } from '@/app/resources/contexts/weavecontext'
import { toggleBool } from '@/app/resources/functions/toggleBool'

import { readWeaveObject } from './functions/set/readWeaveObject'
import { readWeaveObject } from '../../weaveObjHandler/set/readWeaveObject'

export function Uploadweave() {
const { updateGrid } = useContext(WeaveContext) as WeaveContextType
Expand Down
4 changes: 2 additions & 2 deletions app/resources/contexts/weavecontext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//dependencies
import { createContext, useEffect, useState } from 'react'

import { readWeaveObject } from '@/app/components/draft/filehandler/functions/set/readWeaveObject'
import { readWeaveObject } from '@/app/components/draft/weaveObjHandler/set/readWeaveObject'
import { defaultColor, defaultDraftHeight, defaultDraftWidth, defaultShafts, defaultTreadles } from '@/app/resources/constants/weaveDefaults'
import { resizeGrid } from '@/app/resources/functions/resizeGrid'
//exports
Expand Down Expand Up @@ -120,7 +120,7 @@ export function WeaveProvider({ children }: { children: React.ReactElement | Rea
updateGrid('tieup', newGrids.tieupGrid)
updateGrid('warp', newGrids.warpGrid)
updateGrid('weft', newGrids.treadleGrid)
}
}

//Changes content of grid-array depending on cell-id
function updateCell(cellId: string) {
Expand Down

0 comments on commit d933981

Please sign in to comment.