Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Allow to have multiple blocks on the same page #59

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions resources/css/pedigree-chart.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* Form */

/* SVG */
#webtrees-pedigree-chart-container {
.webtrees-pedigree-chart-container {
position: relative;
font-size: unset;
display: flex;
flex: auto;
}

#webtrees-pedigree-chart-container svg {
.webtrees-pedigree-chart-container svg {
display: block;
margin: auto;
cursor: move;
Expand All @@ -19,21 +19,21 @@
/*filter: drop-shadow(3px 1px 3px rgba(0, 0, 0, 0.4));*/
}

#webtrees-pedigree-chart-container svg:active {
.webtrees-pedigree-chart-container svg:active {
cursor: grabbing;
/*cursor: -webkit-grabbing;*/
}

#webtrees-pedigree-chart-container svg .person {
.webtrees-pedigree-chart-container svg .person {
cursor: pointer;
}

#webtrees-pedigree-chart-container svg rect.background {
.webtrees-pedigree-chart-container svg rect.background {
fill: none;
pointer-events: all;
}

#webtrees-pedigree-chart-container div.overlay {
.webtrees-pedigree-chart-container div.overlay {
position: absolute;
top: 0;
left: 0;
Expand All @@ -51,12 +51,12 @@
}

@supports (-webkit-backdrop-filter: none) {
#webtrees-pedigree-chart-container div.overlay {
.webtrees-pedigree-chart-container div.overlay {
-webkit-backdrop-filter: blur(1em);
}
}

#webtrees-pedigree-chart-container div.overlay .tooltip {
.webtrees-pedigree-chart-container div.overlay .tooltip {
font-size: 22px;
color: #5a6268;
position: relative;
Expand All @@ -70,11 +70,11 @@
}

@supports not ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
#webtrees-pedigree-chart-container div.overlay {
.webtrees-pedigree-chart-container div.overlay {
background: rgba(0, 0, 0, 0.5);
}

#webtrees-pedigree-chart-container div.overlay .tooltip {
.webtrees-pedigree-chart-container div.overlay .tooltip {
color: white;
}--
}
22 changes: 11 additions & 11 deletions resources/css/svg.css
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
/* SVG export styles */
#webtrees-pedigree-chart-container svg {
.webtrees-pedigree-chart-container svg {
/* Native font stack: see https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/ */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
min-height: 600px;
}

/* Required for the exported SVG to display properly in Inkscape */
#webtrees-pedigree-chart-container svg.rtl {
.webtrees-pedigree-chart-container svg.rtl {
direction: rtl !important;
unicode-bidi: bidi-override !important;
}

#webtrees-pedigree-chart-container svg text {
.webtrees-pedigree-chart-container svg text {
font-weight: bold;
}

#webtrees-pedigree-chart-container svg rect.female {
.webtrees-pedigree-chart-container svg rect.female {
stroke: var(--sex-f-fg, rgb(255, 32, 128));
stroke-dasharray: none;
stroke-width: 3px;
fill: var(--sex-f-bg, rgb(233, 218, 241));
}

#webtrees-pedigree-chart-container svg rect.male {
.webtrees-pedigree-chart-container svg rect.male {
stroke: var(--sex-m-fg, rgb(129, 169, 203));
stroke-dasharray: none;
stroke-width: 3px;
fill: var(--sex-m-bg, rgb(237, 247, 253));
}

#webtrees-pedigree-chart-container svg rect.unknown {
.webtrees-pedigree-chart-container svg rect.unknown {
stroke: var(--sex-u-fg, rgb(129, 169, 203));
stroke-dasharray: 5;
stroke-width: 3px;
fill: var(--sex-u-bg, rgb(255, 255, 255));
}

#webtrees-pedigree-chart-container svg rect.image {
.webtrees-pedigree-chart-container svg rect.image {
stroke: rgb(175, 175, 175);
}

#webtrees-pedigree-chart-container svg path.link {
.webtrees-pedigree-chart-container svg path.link {
fill: none;
stroke: rgb(175, 175, 175);
stroke-width: 1.5px;
/*shape-rendering: crispEdges;*/
}

#webtrees-pedigree-chart-container svg g.name text {
.webtrees-pedigree-chart-container svg g.name text {
font-weight: bold;
}

#webtrees-pedigree-chart-container svg g.name tspan.preferred {
.webtrees-pedigree-chart-container svg g.name tspan.preferred {
text-decoration: underline;
}

#webtrees-pedigree-chart-container svg text.date {
.webtrees-pedigree-chart-container svg text.date {
fill: rgb(127, 127, 127);
font-weight: normal;
font-size: 13px;
Expand Down
2 changes: 1 addition & 1 deletion resources/js/modules/chart/svg/export/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class SvgExport extends Export
d3.text(cssFile)
.then((data) => {
// Remove parent container selector as the CSS is included directly into the SVG element
data = data.replace(/#webtrees-pedigree-chart-container /g, "");
data = data.replace(/.webtrees-pedigree-chart-container /g, "");

let style = document.createElementNS("http://www.w3.org/2000/svg", "style");
style.appendChild(document.createTextNode(data));
Expand Down
2 changes: 1 addition & 1 deletion resources/js/pedigree-chart.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/views/modules/charts/chart.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare(strict_types=1);
?>

<style>
#webtrees-pedigree-chart-container svg {
.webtrees-pedigree-chart-container svg {
min-height: unset !important;
}
</style>
Expand Down
31 changes: 16 additions & 15 deletions resources/views/modules/pedigree-chart/chart.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ use MagicSunday\Webtrees\PedigreeChart\Configuration;
* @var string $svgStylesheet
* @var array $data The chart data
*/

$id = uniqid();
?>

<div id="webtrees-pedigree-chart-container"></div>
<div class="webtrees-pedigree-chart-container" id="webtrees-pedigree-chart-container-<?= $id ?>"></div>

<?php View::push('styles') ?>
<link rel="stylesheet" href="<?= e($svgStylesheet) ?>">
Expand All @@ -34,37 +36,36 @@ use MagicSunday\Webtrees\PedigreeChart\Configuration;
<?php View::push('javascript'); ?>
<script>

const chartParams = <?= $chartParams ?>;
const cssUrl = <?= json_encode($svgStylesheet) ?>;
const chartParams<?= $id ?> = <?= $chartParams ?>;

const optionGenerations = typeof generations !== "undefined"
const optionGenerations<?= $id ?> = typeof generations !== "undefined"
? generations
: <?= $configuration->getGenerations() ?>;

const optionShowEmptyBox = typeof showEmptyBoxes !== "undefined"
const optionShowEmptyBox<?= $id ?> = typeof showEmptyBoxes !== "undefined"
? showEmptyBoxes
: <?= json_encode($configuration->getShowEmptyBoxes()) ?>;

const optionLayout = typeof treeLayout !== "undefined"
const optionLayout<?= $id ?> = typeof treeLayout !== "undefined"
? treeLayout
: <?= json_encode($configuration->getLayout()) ?>;

// Create chart instance with stored configuration
const pedigreeChart = new WebtreesPedigreeChart.PedigreeChart(
"#webtrees-pedigree-chart-container",
const pedigreeChart<?= $id ?> = new WebtreesPedigreeChart.PedigreeChart(
"#webtrees-pedigree-chart-container-<?= $id ?>",
{
labels : chartParams.labels,
generations : optionGenerations,
showEmptyBoxes : optionShowEmptyBox,
treeLayout : optionLayout,
rtl : chartParams.rtl
labels : chartParams<?= $id ?>.labels,
generations : optionGenerations<?= $id ?>,
showEmptyBoxes : optionShowEmptyBox<?= $id ?>,
treeLayout : optionLayout<?= $id ?>,
rtl : chartParams<?= $id ?>.rtl
}
);

pedigreeChart.cssFile = cssUrl;
pedigreeChart<?= $id ?>.cssFile = <?= json_encode($svgStylesheet) ?>;

// Draw chart
pedigreeChart.draw(<?= json_encode($data) ?>);
pedigreeChart<?= $id ?>.draw(<?= json_encode($data) ?>);

</script>
<?php View::endpush(); ?>