Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre deploy #31

Merged
merged 8 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/components/(userpages)/profile/looms/LoomGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { useEffect, useState } from 'react'

import { Grid_contained } from '@/app/components/draft/draft/Grid_contained'
import { createGrid } from '@/app/components/draft/weaveObjHandler/utils'
import { defaultColor } from '@/app/resources/constants/weaveDefaults'
import { createGrid } from '@/app/resources/functions/utils'
export function LoomGrid(props: { shafts: number, treadles: number }) {

const { shafts, treadles } = props
Expand Down
2 changes: 0 additions & 2 deletions app/components/draft/colorpicker/Colorpicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//Previous colors can be picked again by click and replaced in the draft by changeing
import './colorpicker.scss'

import { useContext } from 'react'

import { Colorinput } from '@/app/components/zSharedComponents/Colorinput'
import { useWeaveContext } from '@/app/resources/contexts/weavecontext'

Expand Down
2 changes: 1 addition & 1 deletion app/components/draft/colorpicker/Colorpicker_contained.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { SetStateAction,useContext, useEffect, useState } from 'react'

import { Colorinput } from '@/app/components/zSharedComponents/Colorinput'
import { useWeaveContext } from '@/app/resources/contexts/weavecontext'
import { replaceColorInGrid } from '@/app/resources/functions/gridHandling/replaceColorInGrid'

import { replaceColorInGrid } from '../weaveGridHandler/replaceColorInGrid'
import { PreviousColor } from './Previouscolor'
export function ColorPicker_contained(props: { warpGrid: grid, updateWarpGrid:(value: SetStateAction<grid>) => void , treadleGrid: grid, updateTreadleGrid:(value: SetStateAction<grid>) => void }) {

Expand Down
2 changes: 1 addition & 1 deletion app/components/draft/draft/Grid_contained.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { ReactElement, SetStateAction, useContext } from 'react'

import { Row } from '@/app/components/draft/draft/Row'
import { useWeaveContext } from '@/app/resources/contexts/weavecontext'
import { updateGrid } from '@/app/resources/functions/gridHandling/updateGrid';

import { updateGrid } from '../weaveGridHandler/updateGrid';
import { CellProps } from './Cell'

interface CellTarget extends EventTarget {
Expand Down
6 changes: 3 additions & 3 deletions app/components/draft/draft/StateDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import './draft.scss'
import {useEffect, useState } from 'react'

import { Grid_contained } from '@/app/components/draft/draft/Grid_contained'
import { createWeave } from '@/app/components/draft/weaveObjHandler/set/writeDraftGrid'
import { Errormsg } from '@/app/components/zSharedComponents/Errormsg'
import { createWeaveObject } from '@/app/resources/functions/weaveObjHandling/createWeaveObj/createWeaveObject'
import { readWeaveObject } from '@/app/resources/functions/weaveObjHandling/readWeaveObj/readWeaveObject'
import { createWeave } from '@/app/resources/functions/weaveObjHandling/readWeaveObj/writeDraftGrid'

import { ColorPicker_contained } from '../colorpicker/Colorpicker_contained'
import { createWeaveObject } from '../weaveObjHandler/get/createWeaveObject'
import { readWeaveObject } from '../weaveObjHandler/set/readWeaveObject'

export function StateDraft(props: { weaveObj: WeaveObject, updateObj:(value: WeaveObject) => void}) {
const {updateObj, weaveObj}=props
Expand Down
4 changes: 2 additions & 2 deletions app/components/draft/draft/Weave.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//This component contains the logic for calculating the weave
import './weave.scss';

import { useContext, useEffect, useState } from 'react'
import { useEffect, useState } from 'react'

import { Grid } from '@/app/components/draft/draft/Grid'
import { useWeaveContext } from '@/app/resources/contexts/weavecontext'
import { resizeGrid } from '@/app/resources/functions/resizeGrid'
import { resizeGrid } from '@/app/resources/functions/gridHandling/resizeGrid';

export function Weave() {
const { draftHeight, draftWidth, treadleGrid, shafts, tieUpGrid, warpGrid } = useWeaveContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { useAuth } from '@clerk/nextjs'

import { createWeaveObject } from '@/app/components/draft/weaveObjHandler/get/createWeaveObject'
import { useWeaveContext } from '@/app/resources/contexts/weavecontext'
import { createWeaveObject } from '@/app/resources/functions/weaveObjHandling/createWeaveObj/createWeaveObject'

export function DbSaveWeave(props: { afterSave: (() => void) | null }) {
const { treadleGrid, tieUpGrid, warpGrid } = useWeaveContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import './draftpreview.scss';

import { useEffect, useState } from 'react'

import { readWeaveObject } from '@/app/components/draft/weaveObjHandler/set/readWeaveObject'
import { PreviewGrid } from '@/app/components/zSharedComponents/PreviewGrid';
import { readWeaveObject } from '@/app/resources/functions/weaveObjHandling/readWeaveObj/readWeaveObject';


export function DraftPreview(params: { weaveObj: WeaveObject }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useContext, useEffect, useState } from 'react'
import Link from 'next/link'

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

import { createWeaveObject } from '../../weaveObjHandler/get/createWeaveObject'
import { createWeaveObject } from '@/app/resources/functions/weaveObjHandling/createWeaveObj/createWeaveObject'

export function Downloadweave() {
const { treadleGrid, tieUpGrid, warpGrid } = useWeaveContext()
Expand Down
5 changes: 2 additions & 3 deletions app/components/draft/draftoptions/filehandler/Uploadweave.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//Contains upload button which accepts json and creates a weaveobject provided the right format
import './uploadweave.scss'

import { useContext, useState } from 'react'
import { useState } from 'react'

import { useWeaveContext } from '@/app/resources/contexts/weavecontext'
import { toggleBool } from '@/app/resources/functions/toggleBool'

import { readWeaveObject } from '../../weaveObjHandler/set/readWeaveObject'
import { readWeaveObject } from '@/app/resources/functions/weaveObjHandling/readWeaveObj/readWeaveObject'

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

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'

import { resizeGrid } from '../functions/gridHandling/resizeGrid'
import { readWeaveObject } from '../functions/weaveObjHandling/readWeaveObj/readWeaveObject'
import { WeaveContextType } from '../types/contexts'
//exports

const WeaveContext = createContext<WeaveContextType | null>(null)

export function WeaveProvider({ children }: { children: React.ReactElement | React.ReactElement[] }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getHighest } from '../utils'
import { getHighest } from '../../utils';

export function collectWarp(warp: grid | undefined) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getHighest } from '../utils'
import { getHighest } from '../../utils';

export function collectWeft(weft: grid | undefined) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defaultDraftWidth, defaultShafts, defaultWarpColor } from '@/app/resources/constants/weaveDefaults'
import { defaultShafts, defaultWarpColor } from '@/app/resources/constants/weaveDefaults'

import { createGrid } from '../utils'
import { createGrid } from '../../utils'


export function readWarp(warp: ShaftDescription, width: number) {
Expand All @@ -11,15 +11,15 @@ export function readWarp(warp: ShaftDescription, width: number) {
return warpGrid
}

let colors = warp.colors
let colorsCopy =JSON.parse(JSON.stringify( warp.colors))

warp.pattern.forEach((thread, index) => {
let currentColor = defaultWarpColor
if (colors) {
currentColor = colors[0].color
colors[0].threads--
if (colors[0].threads = 0) {
colors.shift()
if (colorsCopy) {
currentColor = colorsCopy[0].color
colorsCopy[0].threads--
if (colorsCopy[0].threads == 0) {
colorsCopy.shift()
}
}
warpGrid[thread][index] = currentColor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defaultDraftHeight, defaultDraftWidth, defaultShafts, defaultTreadles } from '@/app/resources/constants/weaveDefaults'

import { createGrid } from '../utils'
import { createGrid } from '../../utils'
import { readTieup } from './readTieup'
import { readWarp } from './readWarp'
import { readWeft } from './readWeft'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defaultDraftHeight, defaultTreadles, defaultWeftColor } from '@/app/resources/constants/weaveDefaults'

import { createGrid, getHighest } from '../utils'
import { createGrid } from '../../utils'


export function readWeft(weft: TreadlingDescription, height: number) {
Expand All @@ -13,18 +13,19 @@ export function readWeft(weft: TreadlingDescription, height: number) {
return weftGrid
}

let colors = weft.colors
let colorsCopy = JSON.parse(JSON.stringify(weft.colors))

//Fill the grid
weft.pattern.forEach((treadle, index) => {
let currentColor = defaultWeftColor
if (colors) {
currentColor = colors[0].color
colors[0].threads--
if (colors[0].threads = 0) {
colors.shift()
if (colorsCopy) {
currentColor = colorsCopy[0].color
colorsCopy[0].threads--
if (colorsCopy[0].threads == 0) {
colorsCopy.shift()
}
}

weftGrid[index][treadle] = currentColor
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//This file exports the function to create a weaveGrid from a gridSet. It also contains the required helperfunctions.
//Returns the color if present for the beat

import { createGrid } from '../utils'
import { createGrid } from '../../utils'

//Returns the color of a specified beat
function getWeftColor(y: number, treadleGrid: grid) {
Expand Down
Loading