Skip to content

Commit

Permalink
wip signup
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Apr 29, 2024
1 parent 55cbb93 commit 1455a81
Show file tree
Hide file tree
Showing 20 changed files with 412 additions and 209 deletions.
2 changes: 1 addition & 1 deletion socket.ini
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ width = 80%

; Minimum height of the window in pixels or as a percentage of the screen.
; default value: 0
min_height = 500
min_height = 650

; Minimum width of the window in pixels or as a percentage of the screen.
; default value: 0
Expand Down
82 changes: 82 additions & 0 deletions src/components/account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { TonicDialog } from '@socketsupply/components/dialog'

class DialogAccount extends TonicDialog {
constructor () {
super()

this.handleResponse = this.handleResponse.bind(this)
}

async show () {
super.show()
window.addEventListener('message', this.handleResponse, { once: true })
}

async hide () {
super.hide()
window.removeEventListener('message', this.handleResponse)
}

async handleResponse (event) {
const iframe = this.querySelector('iframe')
if (event.source !== iframe.contentWindow) return

const app = this.props.app

if (!event.data.success) {
console.error('Unsuccessful data returned', event)
this.resolve(event.data)
await this.hide()
return
}

console.log('GOT RESPONSE FROM STRIPE PAGE', event.data)

try {
const res = await fetch('https://api.socketsupply.co/signup', {
method: 'POST',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event.data)
})

console.log('SIGNUP RESPONSE', res)

if (res.ok) {
const { data: dataUser } = await this.db.state.get('user')
dataUser.buildKeys = await res.json()
console.log('dataUser', dataUser)
await this.db.state.put('user', dataUser)
await this.hide()
}
} catch (err) {
if (err.name === "AbortError") {
this.resolve({ data: event.data })
await this.hide()
}
console.log(err)
}
}

async prompt () {
await this.show()
const { promise, resolve } = Promise.withResolvers()
this.resolve = resolve
return promise
}

render () {
const src = `pages/account.html?dev=${process.env.DEV ? 'true' : 'false'}`

return this.html`
<header>Account</header>
<main>
<iframe src="${src}" border=0></iframe>
</main>
`
}
}

export default DialogAccount
export { DialogAccount }
5 changes: 1 addition & 4 deletions src/components/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DialogConfirm extends TonicDialog {
<tonic-button
value="${button.value}"
async="${isAsync}"
class="${button.class || ''}"
>${button.label}</tonic-button>`
})
}
Expand All @@ -49,10 +50,6 @@ class DialogConfirm extends TonicDialog {
return this.html`
<header>${title}</header>
<main>
<tonic-icon
symbol-id="${type}"
size="24px"
></tonic-icon>
<div class="message">
${message}
</div>
Expand Down
17 changes: 9 additions & 8 deletions src/components/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,15 +654,15 @@ class AppProject extends Tonic {
children: []
}

child.icon = entry.isDirectory() ? 'folder' : 'file'
child.icon = entry.isDirectory() ? '' : 'file'

if (parent.id === 'root' && entry.isDirectory()) {
/* if (parent.id === 'root' && entry.isDirectory()) {
if (!this.props.parent.state.currentProject) {
this.props.parent.state.currentProject = child
}
child.icon = 'package'
}
} */

parent.children.push(child)

Expand Down Expand Up @@ -711,7 +711,7 @@ class AppProject extends Tonic {
isDirectory: false,
nonMovable: true,
type: 'project',
icon: 'package',
icon: '',
children: []
}

Expand Down Expand Up @@ -750,9 +750,9 @@ class AppProject extends Tonic {
const title = (typeof child.title) === 'string' ? child.title : ''
let icon = child.icon

if (!icon || icon === 'folder') {
icon = child.state === 1 ? 'folder-open' : 'folder'
}
// if (!icon || icon === 'folder') {
// icon = child.state === 1 ? 'folder-open' : 'folder'
// }

const iconColor = node.iconColor || 'var(--tonic-primary)'

Expand All @@ -770,7 +770,8 @@ class AppProject extends Tonic {
}
}

const hasToggle = hasChildren > 0 || (icon === 'folder')
const hasToggle = hasChildren > 0 // || (icon === 'folder')

children.push(this.html`
<div class="item">
<div
Expand Down
29 changes: 18 additions & 11 deletions src/components/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,31 @@ class AppProperties extends Tonic {
<tonic-accordion-section
name="preview-windows"
id="preview-windows"
label="Preview Windows"
label="Preview"
>
${previewWindows}
</tonic-accordion-section>
<tonic-accordion-section
name="build-target"
id="build-target"
label="Build Target"
label="Build"
>
<div class="build-controls">
<tonic-select id="device" value="${process.platform}" title="Build Target Platform">
<option value="ios-simulator" data-value="--platform=ios-simulator">iOS Simulator</option>
<option value="android-emulator" data-value="--platform=android-emulator">Android Emulator</option>
<option value="linux" data-value="" disabled>Linux</option>
<option value="darwin" data-value="">MacOS</option>
<option value="win32" data-value="" disabled>Windows</option>
</tonic-select>
</div>
<tonic-checkbox data-section="build-target" id="arch-android" checked="${process.platform === 'android'}" label="Android" title="Android"></tonic-checkbox>
<tonic-checkbox data-section="build-target" id="arch-darwin" checked="${process.platform === 'darwin'}" label="MacOS" title="MacOS/Darwin"></tonic-checkbox>
<tonic-checkbox data-section="build-target" id="arch-ios" checked="${process.platform === 'ios'}" label="iOS" title="iOS"></tonic-checkbox>
<tonic-checkbox data-section="build-target" id="arch-linux" checked="${process.platform === 'linux'}" label="Linux" title="Linux"></tonic-checkbox>
<tonic-checkbox data-section="build-target" id="arch-win32" checked="${process.platform === 'win32'}" label="Windows" title="Windows"></tonic-checkbox>
</tonic-accordion-section>
<tonic-accordion-section
name="deploy"
id="deploy"
label="Deploy"
>
<tonic-checkbox data-section="deploy" id="deploy-apple" disabled="true" checked="false" label="Apple Store" title="Apple Store"></tonic-checkbox>
<tonic-checkbox data-section="deploy" id="deploy-play" disabled="true" checked="false" label="Google Play Store" title="Google Play Store"></tonic-checkbox>
<tonic-checkbox data-section="deploy" id="deploy-ubuntu" disabled="true" checked="false" label="Ubuntu Store" title="Ubuntu Store"></tonic-checkbox>
<tonic-checkbox data-section="deploy" id="deploy-ms" disabled="true" checked="false" label="Microsoft Store" title="Microsoft Store"></tonic-checkbox>
</tonic-accordion-section>
<h3>Project Settings</h3>
Expand Down
52 changes: 52 additions & 0 deletions src/css/component-account.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dialog-account {
display: grid;
grid-template-rows: auto 1fr 60px;
max-width: 900px;
min-width: 650px;
min-height: 580px;
display: grid;
font-family: var(--tonic-monospace);
text-align: center;
}

dialog-account header {
height: 46px;
text-align: center;
padding: 14px;
font-size: 12px;
color: var(--tonic-info);
app-region: drag;
--app-region: drag;
}

dialog-account footer {
height: 60px;
display: grid;
grid-template-columns: 1fr auto;
gap: 12px;
padding: 0 14px;
}

dialog-account tonic-button {
app-region: unset;
--app-region: unset;
place-self: center end;
}

dialog-account p {
margin: 0;
}

dialog-account main {
justify-content: center;
align-content: center;
padding: 0 6%;
}

dialog-account main iframe {
width: 100%;
height: 100%;
border: 0;
app-region: initial;
--app-region: initial;
}
4 changes: 2 additions & 2 deletions src/css/component-confirm.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ dialog-confirm {
display: grid;
grid-template-rows: auto 1fr;
max-width: 500px;
min-height: 280px;
display: grid;
font-family: var(--tonic-monospace);
text-align: center;
Expand Down Expand Up @@ -39,5 +38,6 @@ dialog-confirm p {
dialog-confirm main {
justify-content: center;
align-content: center;
padding: 0 6%;
padding: 4% 6%;
text-align: left;
}
7 changes: 4 additions & 3 deletions src/css/component-project.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app-project {
user-select: none;
content-visibility: auto;
-webkit-user-select: none;
padding: 14px 20px;
padding: 14px 14px;
display: block;
position: absolute;
background-color: var(--tonic-window);
Expand Down Expand Up @@ -131,7 +131,7 @@ app-project .item .handle {
color: var(--tonic-primary);
background: var(--tonic-window);
border-radius: 4px;
margin-left: 24px;
margin-left: 0px;
position: relative;
display: flex;
padding: 4px 0px;
Expand All @@ -153,9 +153,10 @@ app-project .item .handle[data-state="1"] + .node {
app-project .toggle {
position: absolute;
top: 8px;
left: -14px;
left: 14px;
width: 14px;
height: 14px;
z-index: 10;
}

app-project .item .handle[data-state="0"][data-toggle="false"] .toggle {
Expand Down
5 changes: 5 additions & 0 deletions src/css/component-properties.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ app-properties {
bottom: 0;
}

app-properties h3 {
border-bottom: 1px solid;
padding-bottom: 6px;
}

app-properties #project-status {
border: 1px solid var(--tonic-border);
padding: 20px 12px;
Expand Down
2 changes: 1 addition & 1 deletion src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ header.component tonic-button.selected svg use {

header.component#header-properties {
display: grid;
grid-template-columns: 34px 34px 34px 1fr;
grid-template-columns: 34px 34px 34px 34px 1fr;
}

header.component#header-project {
Expand Down
Loading

0 comments on commit 1455a81

Please sign in to comment.