@@ -2,7 +2,6 @@ const nest = require('depnest')
22const dataurl = require ( 'dataurl-' )
33const hyperfile = require ( 'hyperfile' )
44const hypercrop = require ( 'hypercrop' )
5- const hyperlightbox = require ( 'hyperlightbox' )
65const {
76 h, Value, Dict, Struct,
87 map, computed, when, dictToCollection, onceTrue
@@ -20,6 +19,7 @@ exports.needs = nest({
2019 latestValue : 'first' ,
2120 groupedValues : 'first'
2221 } ,
22+ 'app.html.modal' : 'first' ,
2323 'blob.sync.url' : 'first' ,
2424 'keys.sync.id' : 'first' ,
2525 'message.html.confirm' : 'first' ,
@@ -74,8 +74,6 @@ exports.create = function (api) {
7474 new : Value ( api . about . obs . latestValue ( id , 'publicWebHosting' ) ( ) )
7575 } )
7676
77- var lightbox = hyperlightbox ( )
78-
7977 var isPossibleUpdate = computed ( [ name . new , avatar . new , publicWebHosting . new ] , ( name , avatar , publicWebHostingValue ) => {
8078 return name || avatar . link || ( isMe && publicWebHostingValue !== publicWebHosting . current ( ) )
8179 } )
@@ -102,8 +100,12 @@ exports.create = function (api) {
102100 } )
103101 } )
104102
103+ const modalContent = Value ( )
104+ const isOpen = Value ( false )
105+ const modal = api . app . html . modal ( modalContent , { isOpen } )
106+
105107 return h ( 'AboutEditor' , [
106- lightbox ,
108+ modal ,
107109 h ( 'section.avatar' , [
108110 h ( 'section' , [
109111 h ( 'img' , { src : avatarSrc } )
@@ -162,9 +164,9 @@ exports.create = function (api) {
162164 ] )
163165
164166 function dataUrlCallback ( data ) {
165- const cropCallback = ( err , cropData ) => {
167+ const cropEl = Crop ( data , ( err , cropData ) => {
166168 if ( err ) throw err
167- if ( ! cropData ) return lightbox . close ( )
169+ if ( ! cropData ) return isOpen . set ( false )
168170
169171 var _data = dataurl . parse ( cropData )
170172 api . sbot . async . addBlob ( pull . once ( _data . data ) , ( err , hash ) => {
@@ -178,17 +180,17 @@ exports.create = function (api) {
178180 height : 512
179181 } )
180182 } )
181- lightbox . close ( )
182- }
183+ isOpen . set ( false )
184+ } )
183185
184- const cropEl = Crop ( data , cropCallback )
185- lightbox . show ( cropEl )
186+ modalContent . set ( cropEl )
187+ isOpen . set ( true )
186188 }
187189
188190 function Crop ( data , cb ) {
189- var img = h ( 'img' , { src : data } )
191+ var img = h ( 'img' , { src : data } )
190192
191- var crop = h ( 'div' )
193+ var crop = Value ( )
192194
193195 waitForImg ( )
194196
@@ -206,7 +208,7 @@ exports.create = function (api) {
206208 }
207209
208210 var canvas = hypercrop ( img )
209- crop = (
211+ crop . set (
210212 h ( 'PatchProfileCrop' , [
211213 h ( 'header' , 'click and drag to crop your image' ) ,
212214 canvas ,
0 commit comments