Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>
	jquery-data-api
	<span>todo örneği</span>
</header>

<div class="container">
	<form onsubmit="return false">
		<div class="flex-container">
			<div class="flex-item flex-auto">
				<input type="text" data-state="todo" placeholder="Todo başlığınızı yazın">
			</div>
			<div class="flex-item">
				<label>
					<input type="checkbox" data-state="done" value="1">
					Yapıldı olarak işaretle
				</label>
			</div>
			<div class="flex-item flex-button">
				<button type="submit" onclick="addTodo()">Ekle</button>
			</div>
		</div>
	</form>

	<div data-show="$state.todos && $state.todos.length > 0" class="todos">
		<h3>Todo Listesi</h3>
		<ul data-for="todos" data-as="todo">
			<template>
				<li class="{todo.done ? 'done' : ''}" onclick="updateTodo({todo})">
					<span>
						{todo.content}
					</span>
					<button onclick="deleteTodo('{todo.id}', event)">Sil</button>

				</li>
			</template>
		</ul>
		<div class="flex-container" data-show="$state.todos && $state.todos.length > 1">
			<div class="flex-item flex-button">
				<button onclick="reverseTodo()">Sırayı Tersine Çevir</button>
			</div>
		</div>
	</div>
</div>
              
            
!

CSS

              
                * {
    padding: 0;
    margin: 0;
    list-style: none;
    border: 0;
    box-sizing: border-box;
    text-decoration: none;
}

body {
    background: #eee;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif
}

header {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}
header span {
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid #ddd;
    color: rgb(39, 74, 230);
}

.container {
    width: 800px;
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    padding: 15px;
    border-radius: 3px;
    box-shadow: 3px 5px 10px 0 rgba(0,0,0,.1);
}

input[type="text"] {
    width: 100%;
    height: 50px;
    border: 1px solid #ddd;
    padding: 0 15px;
    font-size: 16px;
    border-radius: 3px;
}

.flex-container {
    display: flex;
    gap: 10px;
    align-items: center;
}
.flex-item {
    flex: 1;
}
.flex-auto {
    flex: auto;
}

.flex-button button {
    width: 100%;
    height: 50px;
    background: rgb(39, 74, 230);
    border-radius: 3px;
    font-size: 16px;
    color: #fff;
    cursor: pointer;
}

.todos {
    padding: 15px;
    background: rgba(39, 74, 230, 0.027);
    margin-top: 15px
}

.todos h3 {
    margin-bottom: 10px;
}

.todos ul li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    border-bottom: 1px solid #ddd;
}

.todos ul li button {
    height: 35px;
    padding: 0 15px;
    background: rgb(39, 74, 230);
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
}

.todos ul li span {
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}


.todos ul li.done {
    box-shadow: 3px 0 0 0 green inset;
    padding-left: 10px;
}

.todos ul li.done span {
    text-decoration: line-through;
}
              
            
!

JS

              
                let s4 = () => {
    return Math.floor((1 + Math.random()) * 0x10000)
        .toString(16)
        .substring(1);
  }

setState('todos', []);

const addTodo = () => {
    if (!$state.todo) {
        alert('Lütfen bir todo başlığı belirtin!');
    } else {

        const find = $state.todos.find(t => t.content === $state.todo);
        if (find) {
            alert('Böyle bir todo zaten ekli!');
        } else {

            const newTodo = {
                id: s4(),
                content: $state.todo,
                done: $state.done
            };
            updateState('todos', [newTodo, ...$state.todos]);
            updateState('todo', '')
            updateState('done', false)

        }
    }
}

const deleteTodo = (id, e) => {
    e.stopPropagation();
    updateState('todos', $state.todos.filter(t => t.id !== id));
}

const updateTodo = (todo) => {
    updateState('todos', $state.todos.map(t => {
        if (t.id === todo.id) {
            t.done = !todo.done;
        }
        return t
    }))
}

const reverseTodo = () => {
    updateState('todos', $state.todos.reverse());
}
              
            
!
999px

Console