TIERO Journal
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
}
body {
background: #f5f1ea;
}
/* ==============================
TIERO JOURNAL
================================ */
.tiero-journal-slider {
–cream: #f5f1ea;
–sand: #d8cbbb;
–ink: #161616;
–soft-ink: rgba(22,22,22,.68);
position: relative;
width: 100%;
height: clamp(520px, 75vh, 760px);
overflow: hidden;
background: var(–cream);
}
/* ==============================
LOADING
================================ */
.tiero-loading {
position: absolute;
inset: 0;
z-index: 20;
display: flex;
align-items: center;
justify-content: center;
font-family: “Manrope”, sans-serif;
font-size: 10px;
font-weight: 400;
letter-spacing: .35em;
text-transform: uppercase;
color: #222;
}
/* ==============================
SLIDE
================================ */
.tiero-slide {
position: absolute;
inset: 0;
opacity: 0;
visibility: hidden;
pointer-events: none;
transition:
opacity 1s ease,
visibility 1s ease;
}
.tiero-slide.is-active {
opacity: 1;
visibility: visible;
pointer-events: auto;
z-index: 2;
}
/* ==============================
LINK
================================ */
.tiero-slide-link {
position: relative;
display: block;
width: 100%;
height: 100%;
overflow: hidden;
color: inherit;
text-decoration: none;
}
/* ==============================
IMAGE
================================ */
.tiero-image,
.tiero-placeholder {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
object-position: center;
transform: scale(1.01);
transition:
transform 7s cubic-bezier(.16,1,.3,1),
filter 1s ease;
}
.tiero-slide.is-active .tiero-image,
.tiero-slide.is-active .tiero-placeholder {
transform: scale(1.07);
}
/* fallback */
.tiero-placeholder {
background:
radial-gradient(
circle at 30% 25%,
rgba(255,255,255,.72),
transparent 35%
),
linear-gradient(
135deg,
#ddd2c5,
#c8b8a4
);
}
/* ==============================
OVERLAY
================================ */
.tiero-overlay {
position: absolute;
inset: 0;
z-index: 2;
background:
linear-gradient(
90deg,
rgba(20,16,13,.70) 0%,
rgba(20,16,13,.40) 44%,
rgba(20,16,13,.12) 100%
),
linear-gradient(
180deg,
rgba(20,16,13,.05),
rgba(20,16,13,.35)
);
}
/* ==============================
CONTENT
================================ */
.tiero-content {
position: absolute;
left: clamp(32px, 8vw, 130px);
top: 50%;
z-index: 5;
max-width: 740px;
transform: translateY(-50%);
color: white;
}
/* JOURNAL LABEL */
.tiero-label {
display: block;
margin-bottom: 20px;
font-family: “Manrope”, sans-serif;
font-size: 9px;
font-weight: 400;
letter-spacing: .45em;
text-transform: uppercase;
color: rgba(255,255,255,.78);
opacity: 0;
transform: translateY(12px);
}
.tiero-slide.is-active .tiero-label {
animation:
tieroReveal .8s .1s forwards;
}
/* TITLE */
.tiero-content h2 {
margin: 0;
max-width: 760px;
font-family: “Cormorant Garamond”, Georgia, serif;
font-size: clamp(44px, 6vw, 82px);
font-weight: 400;
line-height: .97;
letter-spacing: -.025em;
text-wrap: balance;
color: white;
opacity: 0;
transform: translateY(25px);
}
.tiero-slide.is-active h2 {
animation:
tieroReveal 1s .18s forwards;
}
/* DESCRIPTION */
.tiero-description {
max-width: 540px;
margin: 26px 0 0;
font-family: “Manrope”, sans-serif;
font-size: 13px;
font-weight: 300;
line-height: 1.75;
letter-spacing: .02em;
color: rgba(255,255,255,.82);
opacity: 0;
transform: translateY(20px);
}
.tiero-slide.is-active .tiero-description {
animation:
tieroReveal .9s .3s forwards;
}
/* READ STORY */
.tiero-read {
display: inline-flex;
align-items: center;
gap: 14px;
margin-top: 30px;
font-family: “Manrope”, sans-serif;
font-size: 9px;
font-weight: 400;
letter-spacing: .38em;
text-transform: uppercase;
color: white;
opacity: 0;
transform: translateY(18px);
}
.tiero-slide.is-active .tiero-read {
animation:
tieroReveal .9s .42s forwards;
}
.tiero-read-arrow {
font-size: 18px;
letter-spacing: 0;
transition:
transform .4s cubic-bezier(.16,1,.3,1);
}
.tiero-slide-link:hover .tiero-read-arrow {
transform: translateX(8px);
}
/* REVEAL */
@keyframes tieroReveal {
to {
opacity: 1;
transform: translateY(0);
}
}
/* ==============================
ARROWS
================================ */
.tiero-arrow {
position: absolute;
top: 50%;
z-index: 10;
width: 48px;
height: 48px;
border: 1px solid rgba(255,255,255,.5);
border-radius: 50%;
background: rgba(255,255,255,.03);
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 26px;
font-weight: 300;
cursor: pointer;
transform: translateY(-50%);
backdrop-filter: blur(8px);
transition:
background .3s ease,
border-color .3s ease,
transform .3s ease;
}
.tiero-arrow:hover {
background: rgba(255,255,255,.15);
border-color: rgba(255,255,255,.9);
transform:
translateY(-50%)
scale(1.05);
}
.tiero-prev {
left: 28px;
}
.tiero-next {
right: 28px;
}
/* ==============================
DOTS
================================ */
.tiero-dots {
position: absolute;
left: 50%;
bottom: 30px;
z-index: 10;
display: flex;
align-items: center;
gap: 8px;
transform: translateX(-50%);
}
.tiero-dots button {
width: 22px;
height: 2px;
padding: 0;
border: 0;
background:
rgba(255,255,255,.38);
cursor: pointer;
transition:
width .35s ease,
background .35s ease;
}
.tiero-dots button.is-active {
width: 50px;
background: white;
}
/* ==============================
MOBILE
================================ */
@media(max-width:768px) {
.tiero-journal-slider {
height: 72vh;
min-height: 600px;
}
.tiero-content {
left: 30px;
right: 30px;
max-width: none;
}
.tiero-content h2 {
font-size: clamp(
40px,
12vw,
62px
);
}
.tiero-description {
font-size: 12px;
max-width: 90%;
}
.tiero-arrow {
width: 38px;
height: 38px;
font-size: 22px;
}
.tiero-prev {
left: 12px;
}
.tiero-next {
right: 12px;
}
.tiero-dots {
bottom: 20px;
}
}
/* REDUCED MOTION */
@media(prefers-reduced-motion:reduce) {
.tiero-image,
.tiero-label,
.tiero-content h2,
.tiero-description,
.tiero-read {
animation: none !important;
transition: none !important;
transform: none !important;
opacity: 1 !important;
}
}
document.addEventListener(
“DOMContentLoaded”,
function () {
/* ===============================
WORDPRESS
=============================== */
const API_ROOT =
“https://nilgunkalkan1-inpmq.wordpress.com/wp-json/wp/v2”;
/* SENİN VERDİĞİN KATEGORİ */
const CATEGORY_ID =
791154525;
/* Kaç içerik */
const POST_COUNT =
6;
/* Otomatik geçiş */
const SLIDE_DELAY =
6000;
const slider =
document.querySelector(
“.tiero-journal-slider”
);
if (!slider) return;
const loading =
slider.querySelector(
“.tiero-loading”
);
const previousButton =
slider.querySelector(
“.tiero-prev”
);
const nextButton =
slider.querySelector(
“.tiero-next”
);
const dotsWrap =
slider.querySelector(
“.tiero-dots”
);
let currentSlide = 0;
let timer = null;
/* ===============================
CLEAN TEXT
=============================== */
function cleanText(html) {
const temp =
document.createElement(“div”);
temp.innerHTML =
html || “”;
return temp.textContent
.replace(/\s+/g, ” “)
.trim();
}
function escapeHTML(text) {
const temp =
document.createElement(“div”);
temp.textContent =
text || “”;
return temp.innerHTML;
}
function safeURL(url) {
if (!url) return “#”;
return String(url)
.replace(
/”/g,
“"”
);
}
/* ===============================
DESCRIPTION
=============================== */
function getDescription(post) {
let description =
cleanText(
post.excerpt?.rendered ||
“”
);
if (!description) {
const temp =
document.createElement(“div”);
temp.innerHTML =
post.content?.rendered ||
“”;
const firstParagraph =
temp.querySelector(“p”);
description =
firstParagraph
? firstParagraph
.textContent
.replace(/\s+/g,” “)
.trim()
: “”;
}
if (
description.length > 180
) {
description =
description
.substring(0,177)
.trim()
+ “…”;
}
return description;
}
/* ===============================
FEATURED IMAGE
=============================== */
function getFeaturedImage(post) {
try {
const media =
post
._embedded
[“wp:featuredmedia”]
[0];
return (
media
.media_details
?.sizes
?.large
?.source_url
||
media
.media_details
?.sizes
?.full
?.source_url
||
media.source_url
||
“”
);
}
catch(error) {
return “”;
}
}
/* ===============================
CREATE SLIDE
=============================== */
function createSlide(
post,
index
) {
const title =
cleanText(
post.title?.rendered ||
“”
);
const description =
getDescription(post);
const link =
safeURL(
post.link
);
const image =
getFeaturedImage(post);
const slide =
document.createElement(
“article”
);
slide.className =
“tiero-slide” +
(
index === 0
? ” is-active”
: “”
);
slide.setAttribute(
“aria-hidden”,
index === 0
? “false”
: “true”
);
slide.innerHTML = `
${
image
? `
`
: `
`
}
TIERO JOURNAL
${escapeHTML(title)}
${
description
? `
${escapeHTML(description)}
`
: “”
}
READ STORY
→
`;
return slide;
}
/* ===============================
DOT
=============================== */
function createDot(index) {
const dot =
document.createElement(
“button”
);
dot.type =
“button”;
dot.setAttribute(
“aria-label”,
`${index + 1}. yazıyı göster`
);
if (index === 0) {
dot.classList.add(
“is-active”
);
}
dot.addEventListener(
“click”,
function(event) {
event.preventDefault();
showSlide(index);
startSlider();
}
);
return dot;
}
/* ===============================
SHOW SLIDE
=============================== */
function showSlide(index) {
const slides =
slider.querySelectorAll(
“.tiero-slide”
);
const dots =
slider.querySelectorAll(
“.tiero-dots button”
);
if (!slides.length) {
return;
}
currentSlide =
(
index +
slides.length
)
%
slides.length;
slides.forEach(
function(
slide,
slideIndex
) {
const isActive =
slideIndex ===
currentSlide;
slide
.classList
.toggle(
“is-active”,
isActive
);
slide.setAttribute(
“aria-hidden”,
isActive
? “false”
: “true”
);
}
);
dots.forEach(
function(
dot,
dotIndex
) {
dot
.classList
.toggle(
“is-active”,
dotIndex ===
currentSlide
);
}
);
}
function nextSlide() {
showSlide(
currentSlide + 1
);
}
function previousSlide() {
showSlide(
currentSlide – 1
);
}
/* ===============================
TIMER
=============================== */
function stopSlider() {
if (timer) {
clearInterval(timer);
timer = null;
}
}
function startSlider() {
stopSlider();
const slides =
slider.querySelectorAll(
“.tiero-slide”
);
if (
slides.length > 1
) {
timer =
setInterval(
nextSlide,
SLIDE_DELAY
);
}
}
/* ===============================
API
=============================== */
async function fetchJSON(url) {
const response =
await fetch(
url,
{
method:
“GET”,
headers: {
Accept:
“application/json”
}
}
);
if (
!response.ok
) {
throw new Error(
“WordPress API: ” +
response.status
);
}
return response.json();
}
/* ===============================
LOAD POSTS
=============================== */
async function loadPosts() {
try {
const postsURL =
`${API_ROOT}/posts`
+
`?categories=${CATEGORY_ID}`
+
`&per_page=${POST_COUNT}`
+
`&orderby=date`
+
`&order=desc`
+
`&_embed=wp:featuredmedia`;
const posts =
await fetchJSON(
postsURL
);
if (
!Array.isArray(posts)
||
!posts.length
) {
throw new Error(
“Kategori içerisinde yazı bulunamadı.”
);
}
if (loading) {
loading.remove();
}
posts.forEach(
function(
post,
index
) {
const slide =
createSlide(
post,
index
);
const dot =
createDot(
index
);
slider.insertBefore(
slide,
previousButton
);
dotsWrap.appendChild(
dot
);
}
);
if (
posts.length === 1
) {
previousButton.style.display =
“none”;
nextButton.style.display =
“none”;
dotsWrap.style.display =
“none”;
}
else {
startSlider();
}
}
catch(error) {
console.error(
“TIERO Journal:”,
error
);
if (loading) {
loading.textContent =
“Journal şu anda yüklenemiyor.”;
}
previousButton.style.display =
“none”;
nextButton.style.display =
“none”;
dotsWrap.style.display =
“none”;
}
}
/* ===============================
BUTTONS
=============================== */
nextButton
.addEventListener(
“click”,
function(event) {
event.preventDefault();
nextSlide();
startSlider();
}
);
previousButton
.addEventListener(
“click”,
function(event) {
event.preventDefault();
previousSlide();
startSlider();
}
);
/* Hover */
slider.addEventListener(
“mouseenter”,
stopSlider
);
slider.addEventListener(
“mouseleave”,
startSlider
);
/* Sekme değiştirilirse */
document.addEventListener(
“visibilitychange”,
function() {
if (
document.hidden
) {
stopSlider();
}
else {
startSlider();
}
}
);
/* START */
loadPosts();
}
);