Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
cc330a9
wip
Highjhacker Jun 14, 2021
8639a66
style: resolve style guide violations
Highjhacker Jun 14, 2021
3649dd7
refactor: removal of js-cookie package
Highjhacker Jun 15, 2021
742f2e5
Merge branch 'feat/external-link-dismiss-cookies' of github.com:ArkEc…
Highjhacker Jun 15, 2021
30cd66d
style: resolve style guide violations
Highjhacker Jun 15, 2021
59ae30b
chore: remove cookies.js file
Highjhacker Jun 15, 2021
b39a518
Merge branch 'feat/external-link-dismiss-cookies' of github.com:ArkEc…
Highjhacker Jun 15, 2021
fd96dba
refactor: suggested changes
Highjhacker Jun 15, 2021
06a4ff6
refactor: suggested changes
Highjhacker Jun 16, 2021
4a3a2c0
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jun 17, 2021
486a1f0
refactor: requested changes
Highjhacker Jun 17, 2021
3d1b073
refactor: requested changes
Highjhacker Jun 18, 2021
9a11bc9
refactor: requested changes
Highjhacker Jun 23, 2021
c1a4832
wip
Highjhacker Jun 23, 2021
397593f
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jun 25, 2021
9735e86
refactor: requested changes
Highjhacker Jun 25, 2021
66df774
wip
Highjhacker Jun 25, 2021
a372ea5
wip
Highjhacker Jun 25, 2021
57a93bf
wip
Highjhacker Jun 28, 2021
ac24236
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jun 28, 2021
f8b023d
refactor: requested changes
Highjhacker Jun 29, 2021
728c38d
refactor: requested changes
Highjhacker Jun 30, 2021
04968ee
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jun 30, 2021
a39cb1f
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jul 1, 2021
9d21072
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jul 2, 2021
cd8e7f6
refactor: requested changes
Highjhacker Jul 2, 2021
7d8d56a
refactor: requested changes
Highjhacker Jul 5, 2021
ecbfa86
Merge branch 'master' into feat/external-link-dismiss-cookies
Highjhacker Jul 6, 2021
b6553d1
Merge branch 'feat/external-link-dismiss-cookies' of github.com:ArkEc…
alfonsobries Jul 13, 2021
fff46f4
Allow `div` and `span` for custom markdown
alfonsobries Jul 13, 2021
afa9465
also allow `span`
alfonsobries Jul 13, 2021
9f5a664
Casting & parsing html
alfonsobries Jul 13, 2021
ef4a55f
Normalize & clean user data
alfonsobries Jul 14, 2021
1917557
No caster
alfonsobries Jul 14, 2021
ebc6681
Remove preview-related stuff
alfonsobries Jul 14, 2021
ffcd914
style: resolve style guide violations
alfonsobries Jul 14, 2021
30e8539
Update msg
alfonsobries Jul 14, 2021
084e5bf
Merge branch 'feat/external-link-dont-show-again' of github.com:ArkEc…
alfonsobries Jul 14, 2021
dc76d66
handle components wIp
alfonsobries Jul 14, 2021
0819170
Fix inline links
alfonsobries Jul 14, 2021
f951d24
Update MarkdownParser.php
alfonsobries Jul 14, 2021
4b7a709
Use a template to simplify parsing
alfonsobries Jul 14, 2021
e4fa8ca
Update MarkdownParser.php
alfonsobries Jul 14, 2021
2b8b520
Note about the template
alfonsobries Jul 14, 2021
835c8ae
cleanuo
alfonsobries Jul 14, 2021
338a36b
Merge branch 'master' of github.com:ArkEcosystem/laravel-ui into feat…
alfonsobries Jul 15, 2021
bccc959
treat string as utf8
alfonsobries Jul 15, 2021
3ccf9c8
Headers handling on full
alfonsobries Jul 15, 2021
88535c9
bold a strong tags
alfonsobries Jul 15, 2021
45b1bd3
ins and lists
alfonsobries Jul 15, 2021
fe85717
Paragraph handling
alfonsobries Jul 15, 2021
b95cfd8
line breaks handling
alfonsobries Jul 15, 2021
22f31f2
Link handling
alfonsobries Jul 15, 2021
1a8b2ca
Handle link contnet
alfonsobries Jul 15, 2021
e05265a
Update MarkdownParser.php
alfonsobries Jul 19, 2021
082606b
Dockblocks
alfonsobries Jul 19, 2021
0b0e06f
Update comment
alfonsobries Jul 19, 2021
f398d8b
Typo
alfonsobries Jul 19, 2021
815e7ce
Update some comments
alfonsobries Jul 19, 2021
3df43f1
Merge branch 'master' into feat/external-link-dont-show-again
alfonsobries Jul 19, 2021
ccbd007
Merge branch 'master' into feat/external-link-dont-show-again
alfonsobries Jul 20, 2021
c3eeadb
Update script
alfonsobries Jul 20, 2021
dd66936
Merge branch 'feat/external-link-dont-show-again' of github.com:ArkEc…
alfonsobries Jul 20, 2021
2d00f82
Rename className for something more general
alfonsobries Jul 20, 2021
32faa0f
Add custom scroll to rich select dropdown
alfonsobries Jul 20, 2021
d49eae0
Update markdown parser classes
alfonsobries Jul 20, 2021
c20e695
Revert "Rename className for something more general"
alfonsobries Jul 20, 2021
0c9a70a
Revert "Add custom scroll to rich select dropdown"
alfonsobries Jul 20, 2021
672ac71
Merge branch 'master' into feat/external-link-dont-show-again
alfonsobries Jul 21, 2021
902c0c4
Fix classes for links
alfonsobries Jul 21, 2021
b96eae1
style: resolve style guide violations
alfonsobries Jul 21, 2021
e6cec74
use regex for the classes
alfonsobries Jul 21, 2021
988ea31
Update tests
alfonsobries Jul 21, 2021
7b49bc4
Merge branch 'feat/external-link-dont-show-again' of github.com:ArkEc…
alfonsobries Jul 21, 2021
d0cf536
Update external icon margin
alfonsobries Jul 21, 2021
bb32789
Merge branch 'master' of github.com:ArkEcosystem/laravel-ui into feat…
alfonsobries Jul 21, 2021
0ac7853
Move comment
alfonsobries Jul 21, 2021
cabdc0f
External link component is now a single modal
alfonsobries Jul 21, 2021
457db73
external link confirm component detects external links
alfonsobries Jul 22, 2021
8053b86
style: resolve style guide violations
alfonsobries Jul 22, 2021
fe76b5e
Add icon to links
alfonsobries Jul 22, 2021
637bf90
Remove deprecated link renderer
alfonsobries Jul 22, 2021
aa25c3d
Merge branch 'feat/external-link-dont-show-again' of github.com:ArkEc…
alfonsobries Jul 22, 2021
8a1db1b
Accept svg icons
alfonsobries Jul 22, 2021
962b097
Merge branch 'master' into feat/external-link-dont-show-again
alfonsobries Jul 26, 2021
3ab2a63
Update src/Support/MarkdownParser.php
alfonsobries Jul 28, 2021
fd5cbb0
Merge branch 'master' of github.com:ArkEcosystem/laravel-ui into feat…
alfonsobries Jul 28, 2021
155a622
Remove console.log
alfonsobries Jul 28, 2021
c5991fe
run `initExternalLinkConfirm` until content loaded
alfonsobries Jul 28, 2021
d041788
Refactor script
alfonsobries Jul 28, 2021
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
53 changes: 29 additions & 24 deletions resources/assets/js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ const Modal = {
previousPaddingRight: undefined,
previousNavPaddingRight: undefined,

defaultOptions: {
defaultSettings: {
reserveScrollBarGap: true,
reserveNavScrollBarGap: true,
},

onModalOpened(scrollable, options = Modal.defaultOptions) {
if (options.reserveScrollBarGap) {
onModalOpened(scrollable, settings = Modal.defaultSettings) {
if (settings.reserveScrollBarGap) {
this.reserveModalScrollBarGap(scrollable);
}

if (options.reserveNavScrollBarGap) {
if (settings.reserveNavScrollBarGap) {
this.reserveNavScrollBarGap(scrollable);
}

disableBodyScroll(scrollable, {
reserveScrollBarGap: !!options.reserveScrollBarGap,
reserveScrollBarGap: !!settings.reserveScrollBarGap,
});

scrollable.focus();
},

onModalClosed(scrollable, options = Modal.defaultOptions) {
if (options.reserveScrollBarGap) {
onModalClosed(scrollable, settings = Modal.defaultSettings) {
if (settings.reserveScrollBarGap) {
this.restoreModalScrollBarGap(scrollable);
}

if (options.reserveNavScrollBarGap) {
if (settings.reserveNavScrollBarGap) {
this.restoreNavScrollBarGap(scrollable);
}

Expand All @@ -48,7 +48,7 @@ const Modal = {
alpine(
extraData = {},
modalName = "",
eventOptions = Modal.defaultOptions
eventSettings = Modal.defaultSettings
) {
return {
name: modalName,
Expand All @@ -57,12 +57,13 @@ const Modal = {
onBeforeShow: false,
onHidden: false,
onShown: false,
options: null,
init() {
const scrollable = this.getScrollable();
if (this.name) {
Livewire.on("openModal", (modalName) => {
Livewire.on("openModal", (modalName, ...options) => {
if (this.name === modalName) {
this.show();
this.show(options);
}
});

Expand All @@ -74,39 +75,43 @@ const Modal = {
}

this.$watch("shown", (shown) => {
if (typeof this.onBeforeShow === "function") {
this.onBeforeShow();
if (shown && typeof this.onBeforeShow === "function") {
this.onBeforeShow(this.options);
}

if (typeof this.onBeforeHide === "function") {
this.onBeforeHide();
if (!shown && typeof this.onBeforeHide === "function") {
this.onBeforeHide(this.options);
}

this.$nextTick(() => {
if (shown) {
if (typeof this.onShown === "function") {
this.onShown();
this.onShown(this.options);
}

Modal.onModalOpened(scrollable, eventOptions);
Modal.onModalOpened(scrollable, eventSettings);
} else {
if (typeof this.onHidden === "function") {
this.onHidden();
this.onHidden(this.options);
}

Modal.onModalClosed(scrollable, eventOptions);
Modal.onModalClosed(scrollable, eventSettings);
}
});
});

if (this.shown) {
Modal.onModalOpened(scrollable, eventOptions);
Modal.onModalOpened(scrollable, eventSettings);
}
},
hide() {
this.options = null;

this.shown = false;
},
show() {
show(options) {
this.options = options;

this.shown = true;
},
getScrollable() {
Expand All @@ -117,18 +122,18 @@ const Modal = {
};
},

livewire(extraData = {}, eventOptions = Modal.defaultOptions) {
livewire(extraData = {}, eventSettings = Modal.defaultSettings) {
return {
init() {
const scrollable = this.getScrollable();

this.$wire.on("modalClosed", () => {
this.$nextTick(() => {
Modal.onModalClosed(scrollable, eventOptions);
Modal.onModalClosed(scrollable, eventSettings);
});
});

Modal.onModalOpened(scrollable, eventOptions);
Modal.onModalOpened(scrollable, eventSettings);
},
getScrollable() {
const { modal } = this.$refs;
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/forms.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
'do_not_show_message_again' => 'Do not show this message again.',
'attachment_pdf' => 'Attachment (.PDF)',
'email' => 'E-Mail Address',
'message' => 'Message',
Expand Down
173 changes: 114 additions & 59 deletions resources/views/external-link-confirm.blade.php
Original file line number Diff line number Diff line change
@@ -1,66 +1,121 @@
@props([
'url',
'text' => null,
'noIcon' => false,
])

@php($identifier = md5($url . '-' . Str::random(8)))

<a
href="javascript:;"
{{-- External icon classes, dont remove are here for purgecss --}}
{{-- inline ml-1 -mt-1.5 --}}
<x-ark-js-modal
name="external-link-confirm"
class="w-full max-w-2xl text-left rounded-xl"
title-class="header-2"
buttons-style="flex justify-end space-x-3"
x-data="{
openModal() {
Livewire.emit('openModal', '{{ $identifier }}')
}
url: null,
hasConfirmedLinkWarning: false,
toggle () {
this.hasConfirmedLinkWarning = ! this.hasConfirmedLinkWarning;
},
onBeforeShow ([ url ]) {
this.url = url;
},
onHidden () {
this.hasConfirmedLinkWarning = false;
document.querySelector('input[name=confirmation]').checked = false;
},
followLink() {
if (this.hasConfirmedLinkWarning) {
localStorage.setItem('has_disabled_link_warning', true)
}

this.hide();
},
}"
class="items-center font-semibold break-all cursor-pointer link"
@click="openModal"
init
>
<span>{{ $text ?? $slot ?? '' }}</span>

@unless($noIcon)
<x-ark-icon name="link" size="sm" class="inline flex-shrink-0 ml-1 -mt-1.5" />
@endunless
</a>

@push('footer')
<x-ark-js-modal
:name="$identifier"
class="w-full max-w-2xl text-left rounded-xl"
title-class="header-2"
buttons-style="flex justify-end space-x-3"
init
>
@slot('title')
@lang('generic.external_link')
@endslot

@slot('description')
<div class="flex flex-col mt-8 space-y-4 whitespace-normal">
<div class="font-semibold text-theme-secondary-900">
<x-ark-alert type="warning" :message="$url" message-class="break-all" />
@slot('title')
@lang('generic.external_link')
@endslot

@slot('description')
<div class="flex flex-col mt-8 space-y-4 whitespace-normal">
<div class="font-semibold text-theme-secondary-900">
<div class="alert-wrapper alert-warning">
<div class="alert-icon-wrapper alert-warning-icon">
<div class="p-1 rounded-full border-2 border-white">
<x-ark-icon
name="warning"
size="xs"
/>

</div>
</div>
<div class="alert-content-wrapper alert-warning-content">
<span class="block leading-6 break-all" x-text="url"></span>
</div>
</div>
<p>@lang('generic.external_link_disclaimer')</p>
</div>
@endslot

@slot('buttons')
<button
class="button-secondary"
@click="hide"
>
@lang('actions.back')
</button>

<a
target="_blank"
rel="noopener nofollow"
class="cursor-pointer button-primary"
href="{{ $url }}"
@click="hide"
<p>@lang('generic.external_link_disclaimer')</p>

<x-ark-checkbox
name="confirmation"
alpine="toggle"
>
@lang('actions.follow_link')
</a>
@endslot
</x-ark-js-modal>
@endpush
@slot('label')
@lang('ui::forms.do_not_show_message_again')
@endslot
</x-ark-checkbox>
</div>
@endslot

@slot('buttons')
<button
class="button-secondary"
@click="hide"
>
@lang('actions.back')
</button>

<a
target="_blank"
rel="noopener nofollow"
class="cursor-pointer button-primary"
:href="url"
@click="followLink()"
>
@lang('actions.follow_link')
</a>
@endslot
</x-ark-js-modal>


<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function (event) {
function initExternalLinkConfirm() {
const selectors = [
'[href*="://"]',
':not([href^="{{ config("app.url") }}"])',
':not([data-safe-external])',
':not([data-external-link-confirm])',
];

const links = document.querySelectorAll(`a${selectors.join('')}`);

links.forEach(function (link) {
link.setAttribute('data-external-link-confirm', 'true');

link.addEventListener('click', function(e) {
if (localStorage.getItem('has_disabled_link_warning') === 'true') {
return;
}

e.preventDefault();

Livewire.emit('openModal', 'external-link-confirm', link.getAttribute('href'));
});
});
}

Livewire.hook("message.processed", function (message, component) {
initExternalLinkConfirm();
});

initExternalLinkConfirm();
});
</script>
15 changes: 9 additions & 6 deletions resources/views/external-link.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'inline' => false,
'allowWrap' => false,
'small' => false,
'noIcon' => false,
])

<a
Expand All @@ -13,11 +14,13 @@ class="{{ $class }} {{ $inline ? 'inline space-x-1' : 'flex items-center space-x
target="_blank"
rel="noopener nofollow noreferrer"
>
<span>{{ $text }}</span>
<span>{{ $slot ?? $text }}</span>

<x-ark-icon
name="link"
:size="$small ? 'xs' : 'sm'"
:class="'flex-shrink-0 '.($inline ? 'inline mr-1 -mt-1' : 'mr-2')"
/>
@unless($noIcon)
<x-ark-icon
name="link"
:size="$small ? 'xs' : 'sm'"
:class="'flex-shrink-0 '.($inline ? 'inline mr-1 -mt-1' : 'mr-2')"
/>
@endunless
</a>
2 changes: 1 addition & 1 deletion resources/views/footer-social.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@

<div class="flex space-x-5">
@foreach($networks as $network)
<x-ark-social-link :url="$network['url']" :icon="$network['icon']" />
<x-ark-social-link :url="$network['url']" :icon="$network['icon']" data-safe-external />
@endforeach
</div>
2 changes: 2 additions & 0 deletions resources/views/inputs/checkbox.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'value' => null,
'checked' => false,
'disabled' => false,
'alpine' => false,
'right' => false
])

Expand Down Expand Up @@ -38,6 +39,7 @@ class="form-checkbox input-checkbox"
@if($value) value="{{ $value }}" @endif
@if($checked) checked @endif
@if($disabled) disabled @endif
@if($alpine) @click="{{ $alpine }}" @endif
/>
</div>

Expand Down
1 change: 1 addition & 0 deletions resources/views/js-modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
])

<div
{{ $attributes }}
x-ref="modal"
data-modal
x-cloak
Expand Down
1 change: 1 addition & 0 deletions resources/views/social-link.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<a
{{ $attributes }}
href="{{ $url }}"
target="_blank"
rel="noopener noreferrer"
Expand Down
Loading