Skip to content

Commit

Permalink
fixup! fix: alignment issue #88 #89
Browse files Browse the repository at this point in the history
  • Loading branch information
unimu-cic committed Dec 4, 2023
1 parent 42c3c68 commit b65e035
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 57 deletions.
47 changes: 31 additions & 16 deletions src/components/DiagramFrame/SeqDiagram/LifeLineLayer/LifeLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
class="lifeline absolute flex flex-col mx-2 transform -translate-x-1/2 h-full"
:style="{ paddingTop: top + 'px', left: left + 'px' }"
>
<div v-show="debug">{{centerOf(entity.name)}}</div>
<div v-show="debug">{{ centerOf(entity.name) }}</div>
<participant v-if="renderParticipants" :entity="entity" :offsetTop="top" />
<div v-else class="line w0 mx-auto flex-grow w-px"></div>
<div v-else class="line absolute inset-0 w0 mx-auto flex-grow w-px"></div>
</div>
</template>

<script>
import parentLogger from '../../../../logger/logger';
import EventBus from '../../../../EventBus';
import { mapGetters, mapState } from 'vuex';
import Participant from './Participant.vue';
const logger = parentLogger.child({ name: 'LifeLine' });
import parentLogger from "../../../../logger/logger";
import EventBus from "../../../../EventBus";
import { mapGetters, mapState } from "vuex";
import Participant from "./Participant.vue";
const logger = parentLogger.child({ name: "LifeLine" });
export default {
name: 'life-line',
name: "life-line",
components: { Participant },
props: ['entity', 'context', 'groupLeft', 'inGroup', 'renderParticipants'],
props: ["entity", "context", "groupLeft", "inGroup", "renderParticipants"],
data: () => {
return {
translateX: 0,
top: 0,
};
},
computed: {
...mapGetters(['centerOf']),
...mapState(['scale']),
...mapGetters(["centerOf"]),
...mapState(["scale"]),
debug() {
return !!localStorage.zenumlDebug;
},
Expand All @@ -43,7 +43,10 @@ export default {
logger.debug(`nextTick after updated for ${this.entity.name}`);
});
EventBus.$on('participant_set_top', () => this.$nextTick(() => this.setTop()));
EventBus.$on("participant_set_top", () =>
// eslint-disable-next-line vue/valid-next-tick
this.$nextTick(() => this.setTop()),
);
// setTimeout( () => {
// this.setTop()
Expand All @@ -65,15 +68,23 @@ export default {
},
methods: {
onSelect() {
this.$store.commit('onSelect', this.entity.name);
this.$store.commit("onSelect", this.entity.name);
},
setTop() {
// escape entity name to avoid 'not a valid selector' error.
const escapedName = this.entity.name.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
const escapedName = this.entity.name.replace(

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
// eslint-disable-next-line no-useless-escape
/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g,
"\\$1",
);
const $el = this.$store.getters.diagramElement;
const firstMessage = $el?.querySelector(`[data-to="${escapedName}"]`);
const isVisible = firstMessage?.offsetParent != null;
if (firstMessage && firstMessage.attributes['data-type'].value === 'creation' && isVisible) {
if (
firstMessage &&
firstMessage.attributes["data-type"].value === "creation" &&
isVisible
) {
logger.debug(`First message to ${this.entity.name} is creation`);
const rootY = this.$el.getBoundingClientRect().y;
const messageY = firstMessage.getBoundingClientRect().y;
Expand All @@ -89,7 +100,11 @@ export default {
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.lifeline .line {
background: linear-gradient(to bottom, transparent 50%, var(--color-border-base) 50%);
background: linear-gradient(
to bottom,
transparent 50%,
var(--color-border-base) 50%
);
background-size: 1px 10px;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:class="{
highlight: isCurrent,
self: isSelf,
'from-no-occurrence': providedFrom && providedFrom !== origin,
'inited-from-occurrence': inheritFromOccurrence,
'right-to-left': rightToLeft,
}"
Expand Down Expand Up @@ -164,7 +165,7 @@ export default {
return this.isSelf ? "SelfInvocation" : "Message";
},
isInitedFromOccurrence: function () {
return this.message?.isInitedFromOccurrence(this.from);
return this.message?.isInitedFromOccurrence(this.context);
},
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
v-on:click.stop="onClick"
:data-signature="signature"
:class="{
'to-occurrence': isToOccurrence,
'right-to-left': rightToLeft,
highlight: isCurrent,
'self-invocation': isSelf,
Expand Down Expand Up @@ -101,11 +102,34 @@ export default {
messageClassNames() {
return this.commentObj?.classNames;
},
isToOccurrence() {
return this.parentCtxIncludeMessage(this.asyncMessage);
},
},
methods: {
onClick() {
this.onElementClick(CodeRange.from(this.context));
},
parentCtxIncludeMessage(current) {
const target = current.Owner();
if (!target) {
return false;
}
current = current?.parentCtx;
while (current) {
if (current.To) {
if (current.To() === target) {
return true;
}
}
current = current.parentCtx;
}
return false;
},
},
components: {
Comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@
<div :style="textStyle" :class="classNames">
{{ content }}
</div>
<div class="absolute right-[100%] top-0 pr-1 group-hover:hidden text-gray-500" v-if="numbering">{{ number }}</div>
<div
class="absolute right-[100%] top-0 pr-1 group-hover:hidden text-gray-500"
v-if="numbering"
>
{{ number }}
</div>
</div>
</div>
<point class="flex-shrink-0 transform translate-y-1/2 -my-px" :fill="fill" :rtl="rtl" />
<point
class="flex-shrink-0 transform translate-y-1/2 -my-px"
:fill="fill"
:rtl="rtl"
/>
</div>
</template>

<script setup lang="ts">
import { useStore } from 'vuex';
import Point from './Point/Point.vue';
import { computed, toRefs, ref } from 'vue';
import { useStore } from "vuex";
import Point from "./Point/Point.vue";
import { computed, toRefs, ref } from "vue";
const props = defineProps<{
context?: any;
content: string;
Expand All @@ -38,35 +47,36 @@ const props = defineProps<{
textStyle?: Record<string, string | number>;
classNames?: any;
number?: string;
}>()
const { context, content, rtl, type, textStyle, classNames, number } = toRefs(props)
const store = useStore()
const messageRef = ref()
const numbering = computed(() => store.state.numbering)
const isAsync = computed(() => type?.value === 'async')
}>();
const { context, content, rtl, type, textStyle, classNames, number } =
toRefs(props);
const store = useStore();
const messageRef = ref();
const numbering = computed(() => store.state.numbering);
const isAsync = computed(() => type?.value === "async");
const borderStyle = computed(() => {
switch (type?.value) {
case 'sync':
case 'async':
return 'solid'
case 'creation':
case 'return':
return 'dashed'
case "sync":
case "async":
return "solid";
case "creation":
case "return":
return "dashed";
}
return ''
})
return "";
});
const fill = computed(() => {
switch (type?.value) {
case 'sync':
case 'async':
return true
case 'creation':
case 'return':
return false
case "sync":
case "async":
return true;
case "creation":
case "return":
return false;
}
return false
})
return false;
});
const onClick = () => {
store.getters.onMessageClick(context, messageRef.value)
}
</script>
store.getters.onMessageClick(context, messageRef.value);
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ onUpdated(() => {
border-right-width: 7px;
}
.alt,
.fragment {
.interaction.sync {
border-left-width: 7px;
//border-right-width: 0;
}
}
.occurrence {
.occurrence {
.interaction.sync,
Expand All @@ -86,17 +78,25 @@ onUpdated(() => {
.occurrence {
.interaction.sync,
.interaction.async {
border-left-width: 7px;
border-left-width: 8px;
}
.interaction.sync.right-to-left {
border-right-width: 7px;
}
.interaction.async.right-to-left {
border-right-width: 7px;
border-left-width: 7px;
}
.interaction.async.right-to-left {
border-left-width: 0;
}
.interaction.sync.from-no-occurrence {
border-left-width: 0;
}
.interaction.async.right-to-left.to-occurrence {
border-left-width: 7px;
}
}
.interaction.sync.right-to-left {
/* This border width configuration make sure the content width is
the same as from the source occurrence's right border to target
Expand Down

0 comments on commit b65e035

Please sign in to comment.