Giter Site home page Giter Site logo

Comments (3)

Chandrababu-Namani avatar Chandrababu-Namani commented on June 4, 2024 1

This issue can be resolved through the following code:
HTML:

<div class="container">
 <div class="wrap">
   <div class="box">
     <p data-copy-text="">pip install Django==4.2</p>
   </div>
 </div>
</div>

CSS:

  font-size: 16px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  line-height: 1;
  border: 0;
}
html,
body {
  width: 100vw;
  min-width: 100vw;
  height: 100vh;
  min-height: 100vh;
}
body {
  background-color: #f5f5f4;
  font-family: 'Catamaran', sans-serif;
}
p {
  font-size: 1.25rem;
  line-height: 1.25;
}
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}
.container .wrap {
  flex: 0 1 37.5rem;
  margin: 0.625rem;
}
.container .wrap .box {
  padding: 1.25rem;
  background-color: #fff;
  border: 0.0625rem solid #607d8b;
  border-radius: 0.1875rem;
}
.container .wrap .box:not(:last-child) {
  margin-bottom: 1.5625rem;
}
[data-copy-text] + i.material-icons {
  transition: all 0.25s ease-in-out;
  position: absolute;
  top: 0;
  right: 0;
  background-color: #f5f5f4;
  padding: 0.3125rem 0.625rem;
  color: #000;
  border-color: #607d8b;
  border-style: solid;
  border-top-right-radius: 0.1875rem;
  border-bottom-width: 0.0625rem;
  border-left-width: 0.0625rem;
  opacity: 0.3;
  cursor: pointer;
  z-index: 1;
}
[data-copy-text] + i.material-icons:hover,
[data-copy-text] + i.material-icons.active {
  background-color: #607d8b;
  opacity: 1;
  color: #fff;
}```
JavaScript:

'use strict';

document.addEventListener('DOMContentLoaded', function() {
copyText.init()
});

var copyText = {
init: function() {
if (document.querySelectorAll('[data-copy-text]').length) {
var cp = document.querySelectorAll('[data-copy-text]');

		for (var i = 0, l = cp.length; i < l; i++) {
			copyText.addCopy(cp[i]);
		}
	}
},
addCopy: function(el) {
	if (typeof el !== 'undifined') {
		var parent = el.parentNode;
		if (!parent.querySelectorAll('span.copy-btn').length && window.getSelection) {
			var cpBtn = document.createElement('I');

			parent.setAttribute('style', 'position:relative');
			parent.appendChild(cpBtn);

			cpBtn.classList.add('material-icons');
			cpBtn.textContent = 'content_copy';
    cpBtn.innerHTML = '&#xf0c5;';

			cpBtn.setAttribute('title', 'Copy Text');

			copyText.addCopyEvent(cpBtn, el);
		}
	}
},
addCopyEvent: function(btn, el) {
	var coppied = false;
	var timer = 0;

	function copyText() {
		function showCheckmark() {
			btn.textContent = 'check';
			btn.classList.add('active');
		}

		function hideCheckmark() {
			btn.classList.remove('active');
			btn.textContent = 'content_copy';
			timer = 0;
		}
		
		if (timer === 0) {
			if (window.getSelection) {
				var selection = window.getSelection();
				var range = document.createRange();
				range.selectNodeContents(el);
				selection.removeAllRanges();
				selection.addRange(range);

				try {
					document.execCommand('copy');
					coppied = true;
				} catch (err) {
					console.error(err);
				}

				selection.removeAllRanges();
			} else {
				console.error('your browser does not support copy');
			}

			if (coppied) {
				clearTimeout(timer);
				showCheckmark();
				timer = setTimeout(hideCheckmark, 2000);
			}
		}
	}

	if (typeof btn !== 'undifined' && typeof el !== 'undifined') {
		btn.addEventListener('click', copyText, false);
	}
},

}

**I hope the reviewer finds these code snippets useful for the improvement of their download page, So assign this to me I'll resolve it super fast. I want to contribute to Django.**

Before :

![image](https://user-images.githubusercontent.com/83120798/229566139-bc5d887c-db26-4f7a-b2dd-2230454d7209.png)


After :
![image](https://user-images.githubusercontent.com/83120798/229566297-7be1828f-1c3b-4d67-9950-8c1f3303c0e1.png)

from code.djangoproject.com.

cleverhare avatar cleverhare commented on June 4, 2024

@Chandrababu-Namani Great brother, can you attach some screenshot so that reviewer can review it super fast, and I would also hope this issue would get assigned to you brother

from code.djangoproject.com.

sarahboyce avatar sarahboyce commented on June 4, 2024

You also raised the issue at djangoproject.com, which is the correct repository.
django/djangoproject.com#1338

I think this issue should be closed and handled in djangoproject.com 👍

from code.djangoproject.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.