Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
be383aa5
Commit
be383aa5
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
refactor(client): use composition api
parent
85365da6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/client/src/components/global/spacer.vue
+46
-63
46 additions, 63 deletions
packages/client/src/components/global/spacer.vue
with
46 additions
and
63 deletions
packages/client/src/components/global/spacer.vue
+
46
−
63
View file @
be383aa5
...
...
@@ -6,78 +6,61 @@
</div>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
setup
>
import
{
inject
,
onMounted
,
onUnmounted
,
ref
}
from
'
vue
'
;
import
{
deviceKind
}
from
'
@/scripts/device-kind
'
;
import
{
defineComponent
,
inject
,
onMounted
,
onUnmounted
,
ref
}
from
'
vue
'
;
export
default
defineComponent
({
props
:
{
contentMax
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
marginMin
:
{
type
:
Number
,
required
:
false
,
default
:
12
,
},
marginMax
:
{
type
:
Number
,
required
:
false
,
default
:
24
,
},
},
const
props
=
withDefaults
(
defineProps
<
{
contentMax
?:
number
|
null
;
marginMin
?:
number
;
marginMax
?:
number
;
}
>
(),
{
contentMax
:
null
,
marginMin
:
12
,
marginMax
:
24
,
});
setup
(
props
,
context
)
{
let
ro
:
ResizeObserver
;
const
root
=
ref
<
HTMLElement
>
();
const
content
=
ref
<
HTMLElement
>
();
const
margin
=
ref
(
0
);
const
shouldSpacerMin
=
inject
(
'
shouldSpacerMin
'
,
false
);
const
adjust
=
(
rect
:
{
width
:
number
;
height
:
number
;
})
=>
{
if
(
shouldSpacerMin
||
deviceKind
===
'
smartphone
'
)
{
margin
.
value
=
props
.
marginMin
;
return
;
}
let
ro
:
ResizeObserver
;
let
root
=
$ref
<
HTMLElement
>
();
let
content
=
$ref
<
HTMLElement
>
();
let
margin
=
$ref
(
0
);
const
shouldSpacerMin
=
inject
(
'
shouldSpacerMin
'
,
false
);
if
(
rect
.
width
>
props
.
contentMax
||
(
rect
.
width
>
360
&&
window
.
innerWidth
>
400
))
{
margin
.
value
=
props
.
marginMax
;
}
else
{
margin
.
value
=
props
.
marginMin
;
}
};
const
adjust
=
(
rect
:
{
width
:
number
;
height
:
number
;
})
=>
{
if
(
shouldSpacerMin
||
deviceKind
===
'
smartphone
'
)
{
margin
=
props
.
marginMin
;
return
;
}
onMounted
(()
=>
{
ro
=
new
ResizeObserver
((
entries
)
=>
{
/* iOSが対応していない
adjust({
width: entries[0].borderBoxSize[0].inlineSize,
height: entries[0].borderBoxSize[0].blockSize,
});
*/
adjust
({
width
:
root
.
value
!
.
offsetWidth
,
height
:
root
.
value
!
.
offsetHeight
,
});
});
ro
.
observe
(
root
.
value
!
);
if
(
rect
.
width
>
(
props
.
contentMax
??
0
)
||
(
rect
.
width
>
360
&&
window
.
innerWidth
>
400
))
{
margin
=
props
.
marginMax
;
}
else
{
margin
=
props
.
marginMin
;
}
};
if
(
props
.
contentMax
)
{
content
.
value
!
.
style
.
maxWidth
=
`
${
props
.
contentMax
}
px`
;
}
onMounted
(()
=>
{
ro
=
new
ResizeObserver
((
entries
)
=>
{
/* iOSが対応していない
adjust({
width: entries[0].borderBoxSize[0].inlineSize,
height: entries[0].borderBoxSize[0].blockSize,
});
onUnmounted
(()
=>
{
ro
.
disconnect
();
*/
adjust
({
width
:
root
!
.
offsetWidth
,
height
:
root
!
.
offsetHeight
,
});
});
ro
.
observe
(
root
!
);
if
(
props
.
contentMax
)
{
content
!
.
style
.
maxWidth
=
`
${
props
.
contentMax
}
px`
;
}
});
return
{
root
,
content
,
margin
,
};
},
onUnmounted
(()
=>
{
ro
.
disconnect
();
});
</
script
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment